Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Apply Named Template to every Control on UserControl

$
0
0
I have named Styles and Templates in my App.xaml file. I can apply these to each control throughout my project. I have a UserControl with X number of Buttons. Instead of specifying each Button's style, I was able to use BasedOn:
<UserControl ...>
   <UserControl.Resources>
      <Style TargetType={x:Type Button}" BasedOn="{StaticResource styBigButtons}">
         <Setter Property="Margin" Value="10" />
      </Style>
   </UserControl.Resources>
<Grid>
   ///This is a very condensed example so we can get to the point
   <Button Name="btn1" Content="1" Template="{StaticResource ctRedButton}" />
   ...
   <Button Name="btn9" Content="9" Template="{StaticResource ctRedButton}" />
</Grid>
</UserControl>


This has saved a lot of typing to specify which style to use on this page. Is there a way to set all Buttons' Templates on this page using a named Template I already have? It would make sense for this to be possible.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>