Wednesday, February 14, 2007

theWPFblog » Examples

 

In the couple of days that I’ve been experimenting with WPF/E, I have finally come to terms with how it all works and what you need to create a new project. Microsoft has released a template for Visual Studio but I think that it does more harm than good. Plus it only currently works in the full version of VS and not in the express editions. In this post I will explain the basic building blocks that make up a WPF/E application. I’ll use the typical Hello World scenario.

HelloWorld.xaml
Your XAML file is the heart of the WPF/E application. Much like in WPF, XAML defines all of the visual interface and animations. You can create the XAML code in Blend, Visual Studio, or in Notepad. Visual Studio gives you Intellisense code completion but since XAML is XML-based, any XML editor will speed things up. Using Blend is great for visually laying out your graphics, but it spits out WPF XAML not WPF/E XAML so you will have strip down the resulting code to make everything Canvas-based.

To create a compliant XAML file you need to use a Canvas as your root element with the two namespace declarations seen below. Then to add the Hello World text I’m simply adding a TextBlock control to the Canvas.

Source: theWPFblog » Examples

No comments: