Skip to main content

Microsoft Silverlight

Answered Question Setting Default Template of an Element TypeRSS Feed

(0)

philjones
philjones

Member

Member

60 points

106 Posts

Setting Default Template of an Element Type

 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!

 

---
Phil Cockfield

nyhetsgrupper@gmail.com
nyhetsgr...

Participant

Participant

1372 points

320 Posts

Answered Question

Re: Setting Default Template of an Element Type

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

Please click the "Mark as answer" link if this answered your question

Roger Gullhaug
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities