Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Setting Default Template of an Element Type
1 replies. Latest Post by nyhetsgrupper@gmail.com on April 11, 2009.
(0)
philjones
Member
60 points
106 Posts
04-11-2009 12:25 AM |
I think I'm missing something basic here, but I can't figure out how to set the default template for any given element type. For example, if I have a resource dictionary with:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <Style TargetType="Button"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Border Background="HotPink" Width="120" Height="20"></Border> </ControlTemplate> </Setter.Value> </Setter> </Style></ResourceDictionary>
And I reference that dictionary in my control. Because I haven't given it a specific key I thought it would apply to all Button's in the control. But it doesn't.
What am I missing, and I totally off track here?
If so, how can I set a generic template for a particular type?
Thanks!
nyhetsgr...
Participant
1372 points
320 Posts
04-11-2009 6:07 AM |
To be able to set styles for all buttons like this you have to use the ImplicitStyleManger (ISM) from the Silverlight toolkit.You can see a sample here: http://silverlight.net/samples/sl2/toolkitcontrolsamples/run/default.html