Tip of the Day #24: How to Apply a XAML Template to a Class
Posted In: Official SilverLight by adminLet’s say you have a class where you want to declare elements via a XAML template instead of dynamically creating them. For example, the XAML to declare an image and add it to a canvas would look like this: <Canvas x:Name= "MyCanvas" > <Image x:Name= "MyImage" Source= "Grass.png" ></Image> </Canvas> To do the same thing programmatically you would need to declare the following code: Image myImage = new Image(); Uri uri = new Uri( "Grass.png"…(read more)
Read full story
