|
||||||||||||||||||
Building the User Interface Using XAML The good news is that you can use another tool from MicrosoftExpression Blendto build the XAML UIs. Microsoft Expression Blend is a professional design tool that allows you to build professional looking UI for Windows application. The latest edition of Blend, Expression Blend 2 March Preview, allows you to create Silverlight-based applications (you can obtain a preview copy from the links provided earlier in the article). To open the Page.xaml file with Expression Blend 2, right-click on it and select Open in Expression Blend… (see Figure 4).
Expression Blend 2 will launch and you will see an environment somewhat similar to Visual Studio 2008 (see Figure 5). Let's now add some controls to the page. First, you'll create a rounded-corner button on the page that looks like Figure 6). Within this button, you'll also add a text block so that you can use it to display some information.
First, click on the Canvas control (see Figure 7) and add it to the page. This canvas will act as a container that contains all the controls that make up the button. To create a border for the button, add a Rectangle control to the page, essentially covering the canvas that you have just added (see Figure 8). To create the four rounded corners, click on the Direction Selection icon and then select the Rectangle control that you have just added (see Figure 9). Set the properties of the Rectangle control as follows:
To display text within the button, you need to add a TextBlock control onto the canvas (see Figure 10). Also, set the font to Comic Sans MS. To make the button display the current time, you need to update the time every second. To do so, add a Timeline to your XAML file. First, click on the > arrow in the Objects and Timeline group, followed by the + button (see Figure 11).
You will be asked to name the new Timeline. Use the default name of Timeline1 and click OK. Your XAML file will now look like Figure 12. Save the XAML file. When you now return to Visual Studio 2008, it will ask you if you want to reload the Page.xaml file as it has been edited outside the source editor. Once you have reloaded the file, you will now see the following XAML content (see Listing 5).
To make the canvas object accessible programmatically, add the x:Name attribute and set it to btnTime, like this:
Note that in Expression Blend 2, you can switch between Design and XAML views (see Figure 13). Unfortunately, there is no IntelliSense support in XAML view.
|
||||||||||||||||||
|
Submit article to:
|