Page 1 of 1

WPF for the WinForms coder - Part 2

#1 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5442
  • View blog
  • Posts: 11,676
  • Joined: 02-June 10

Posted 30 April 2013 - 11:52 AM

*
POPULAR

Learning C# Series

WPF for the WinForms coder

Part 2 - Some additions to Visual Studio to make your life better




This isn't exactly a "tutorial" but is a part of this 'WPF for the WinForms coder' transitional series.

We all know that Visual Studio is extensible, meaning people write extensions for it to give it new or better features. There are a few of these I'd like to point out because I would't want to do without them if I didn't have to. They can be obtained through the Microsoft Extension Library on line. If you've never done this, its quite easy. From your Tools menu select Updates and Extensions. Then Online. Then Visual Studio Gallary

The first extension gives us our familiar #region directive from C#, within XAML. XAML gets long and can become confusing because of how so many controls get nested inside other controls. Use regions to lable and compact your XAML lets you find what you want and focus on just what you are working on.

Attached Image


Do a search in the Visual Studio Galler for "XAML Regions".

Attached Image


Two more are XAML Formatter and XAML Styler. These give you more and automatic control on how your XAML is, well, formatted. For example I like each attribtute to be on its own line like this
                <TextBox MinWidth="75"
                         Margin="0,0,5,0"
                         Text="{Binding ElementName=thisWindow,
                                        Path=FirstName,
                                        Mode=TwoWay,
                                        UpdateSourceTrigger=PropertyChanged}" />

Instead of long horizontal lines of tags like this
 
                <TextBox MinWidth="75" Margin="0,0,5,0" Text="{Binding ElementName=thisWindow, Path=FirstName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

Because I don't like doing lots of horizontal scrolling just as you have to do here. Also, one of these (I forget which) will cause the XAML document to be reparsed and cleaned up according to our set rules automatically every time you save.

The next thing that every WPF developer needs is the WPF Extended toolkit. This is free. It is available on CodePlex. It provides numerous controls you want/need/expect and are used to having such as numeric up/down controls, DateTime pickers, magnifier tool and so on. This is a well maintained library with regular updates.

Once you have downloaded and unzipped,
put in a place where you keep all your included DLLs and libraries. For example, mine is [color='blue]K:\Code\Includes\[\color]
Add a new tab to your Toolbox pallet.
Attached Image

Now follow the instructions on the new tab: Drag-n-drop the DLL to the Toolbox pallet.

Attached Image


Now you have all these new controls available to you.

Attached Image


Is This A Good Question/Topic? 5
  • +

Page 1 of 1