Prev | Current Page 145 | Next

Matthew MacDonald

"Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5"


CHAPTER 2 n XAML 48
nNote Some developers get around these limitations by creating custom wrapper classes. For example,
the FileStream class doesn??™t include a no-argument constructor. However, you could create a wrapper class
that does. Your wrapper class would create the required FileStream object in its constructor, retrieve the
information it needs, and then close the FileStream. This type of solution is seldom ideal because it invites
hard-coding information in your class constructor and it complicates exception handling. In most cases, it??™s
a better idea to manipulate the object with a little event handling code and leave it out of your XAML entirely.
The following example puts it all together. It maps the sys: prefix to the System namespace
and uses the System namespace to create three DateTime objects, which are used to fill
a list:
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Width="300" Height="300"
>


10/13/2010 4:30 PM


10/29/2010 12:30 PM


10/30/2010 2:30 PM



Loading and Compiling XAML
As you??™ve already learned, XAML and WPF are separate, albeit complementary, technologies.


Pages:
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157