I need sample WPF controls without XAML

I have a good WPF book, but I need some code examples to program the system without using a lot of XAML markup. In particular, I want a summary of the individual text controls and events.

So I want a website or book, not a snotty comment: P

Please note: stay on topic! I do not criticize the system. Thanks.

+4
source share
6 answers

Glen, unfortunately, for you WPF is not built for use through code. Although you can do something through code, it is much harder to do. WPF is built as data-based, so to manage the user interface you need to manipulate the data, not the controls. This is a tricky question, but lets say that controls may or may not exist at run time based on their current visibility on the screen and other properties.

If you still want to experiment with this, you can check the controls in the System.Windows.Controls namespace. When you need to create a ControlTemplate or DataTemplate, you can use FrameworkElementFactory .

For example, how difficult it can be, you can take a look at this question. For this reason, MS assumes that even when you need to manipulate WPF with code, you must put XAML in a string and load it using XamlReader.Load () (this sentence is in the Remarks section of FrameworkElementFactory ).

+3
source

I'm not quite sure what you are asking because XAML is just a markup language.

If you take something like

<Button Name="MyButton" Content="Test" /> 

you really say

 Button b = new Button(); b.Name = "MyButton"; b.Content = "Test"; 

I don’t think there is a need to create a tutorial on how to make WPF controls using code, because the markup language does almost the same thing, and in most cases it is very easy to convert what you see into the markup language for the code .

And if you really need examples of how to create a specific control using code, you can usually find many code examples through Google.

+4
source

This is the one where I started with WPFTutorials

+3
source

http://msdn.microsoft.com/en-us/library/ms754130.aspx

as Ed S. suggested, this is the MSDN entry for WPF. On the left there is a link to the controls. Each control has a link about what they do, why they are needed, etc.

I found this WPF / Winform comparison useful:

http://msdn.microsoft.com/en-us/library/ms750559(v=VS.90).aspx

+2
source

If you want to know more about WPF , you can take a look at this blog . You will find a lot of useful information about WPF .

Hello

Debasis

+1
source

If you really want to learn WPF "code-first", there really is only one primary resource that I know of:

Sales and programming Griffiths WPF

They approach WPF in terms of code. I do not think that haml was even introduced before the second half of the (rather large) book.

Note that you will also learn to do things in the “old” way when newer versions of WPF learned Silverlight lessons, etc. (e.g. triggers and VisualStateManager)

+1
source

All Articles