As title really
I'm writing an interface at the moment in WPF/.NET3, using primarily XAML and a bit of C# codebehind for animations etc..and just thought I would mention how nice it is to use - a real step up from the WinForms of the past.
Orcas is a great tool for developing it with (as long as you ignore the designer), even with the intellisense bugs that exist at the moment..but then you have to forgive it that at the moment as it is a Microsoft beta after all
Some examples of why I think its cool? Lets take how simple it is to create a control and apply a style/layout to a range of them..for example Textblocks.
You create your textblocks, as shown below:
Code:
<TextBlock Text="Text" />
As you can see, it looks just like a bit of XHTML code, or XML The above tag is like a label of winforms, but much more flexible. I could also specify that block like this if I wanted, which is suitable for longer lines of text.
Code:
<TextBlock>
This is a longer line of text!
</TextBlock>
To add more properties to this textblock, you can do things in a multitude of ways..for example, if you just wanted to apply the property to this single block, you could do this:
Code:
<TextBlock x:Name="txtblkTextBlock1" FontWeight="Bold" FontSize="12" TextWrapping="Wrap">
This is bold text, of size 12 which will wrap accross multiple lines!
</TextBlock>
Or, this codeblock does exactly the same thing.
Code:
<TextBlock x:Name="txtblkTextBlock1">
<TextBlock.FontWeight>
Bold
</TextBlock.FontWeight>
<TextBlock.FontSize>
12
</TextBlock.FontSize>
<TextBlock.TextWrapping>
Wrap
</TextBlock.TextWrapping>
This is bold text, of size 12 which will wrap accross multiple lines, declared using property tags!
</TextBlock>
but what if you wanted to apply the above style to lots of textblocks? Thats simple too, and works in a similar way to CSS. You simply add a resource section to your application, with code like this. Your basically giving the codeblock a class (the 'Key'), a type ('x:Type'), and then setting each property (the 'Setter's), which can also be written out in the long <Style.Setter.Property.PropertyName> format if you do desire.
Code:
<Window.Resources>
<Style x:Key="ExampleTextStyle" TargetType="{x:Type TextBlock}">
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="FontSize" Value="12" />
<Setter Property="TextWrapping" Value="Wrap" />
</Style>
</Window.Resources>
and then replace all your property tags with a single ID, like so
Code:
<TextBlock x:Name="txtblkTextBlock1" Style="{StaticResource ExampleTextStyle}" >
This is a styled textblock!
</TextBlock>
Simple! Thats just a very basic example, you can get much more complex with nested blocks/controls, clever animations, transformations, gradients etc..all with the same sort of familiar XML/XHTML like syntax.
It can make GUI programming so much easier to visualise, especially if you come to Windows programming from a primarily web based background. Another advantage is that everything produced with WPF uses vector graphics, meaning it looks great at almost any resolution or zoom level - this is also what gives it the transformation power, allowing you to manipulate any aspect of the interface on the fly without having to design the artwork first of all (eg a rotating image is a simple, 3 lines of C# code ) I've not even touched on the layout managers and new methods of relative positioning which make auto-resizing very simple to do - without the typical layout nightmares that relative positions/auto-resizing usually causes with desktop applications..or for that matter WPF/E (silverlight), which is WPF for web browsers (the next step up from ASP.NET).
Anyway just wanted to share with you all some of the cool things I've found about WPF since I've been learning it today..I was convinced that .NET was the future of Windows programming when verison 2.0 was released..but with 3.0 and 3.5(beta) I am even more convinced lol