Examining Various Silverlight Containers
page 6 of 8
by Brian Mains
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 39610/ 128

Resources

The Silverlight framework (as well as WPF) provides a resource location to store objects within it.  Resources are available at the application level, user control level, and pretty much every-other-control-level that it's very handy to create a reusable template through this scenario, such as:

Listing 8: Reusing control templates

 
<UserControl.Resources>
    <ControlTemplate x:Key="MyCustomTemplate">
         <Border BorderBrush="Beige" BorderThickness="2">
            <TextBlock Margin="20" Text="My templated content via resources" />
        </Border>
     </ControlTemplate>
 </UserControl.Resources>
.
.
<HeaderedContentControl HeaderTemplate="{StaticResource MyCustomTemplate}" />

Any control can override the default template by providing a custom template using the StaticResource keyword.  This keyword designates a resource stored in the UserControl's resources collection, and will dynamically supply the template at runtime.


View Entire Article

User Comments

Title: Microsoft.Windows.Controls   
Name: Evgen
Date: 2010-08-26 4:42:38 AM
Comment:
May be
Microsoft.Windows.Controls
instead of
System.Windows.Controls
?
Title: Silverlight   
Name: Prabhakar
Date: 2009-07-15 7:51:36 AM
Comment:
This is article very useful. I have query "Can we add a xmal file inside any panel/etc.." I want to display all my xaml files/controls to display in one page. Please advice me if it is possible.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2018 ASPAlliance.com  |  Page Processed at 2018-09-26 11:19:52 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search