I want to set the style of some controls on my UserControl, but can't seem to find the right syntax:
<UserControl x:Class="HiideSRM.WIDSModule.BiometricStatusIndicator"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Style TargetType="{x:Type Border}">
<Setter Property="Width" Value="10"/>
</Style>
<StackPanel Orientation="Horizontal" x:Name="Panel">
<Border Height="50" Margin="1"/>
<Border Height="10" Margin="1"/>
<Border Height="10" Margin="1"/>
<Border Height="10" Margin="1"/>
</StackPanel>
</UserControl>
first, place your styles into a .Resources tag--which can be the child of pretty much any control tag (eg. border, usercontrol, grid, etc.) second, you can specify the style in the tag, but since you didnt declare an x:key on your resource, the style will apply to ALL borders in this control.
<UserControl.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="Width" Value="10"/>
</Style>
</UserControl.Resources>
note that the syntax is different for silverlight. instead of TargetType="{x:Type Border}"
you would use TargetType="Border"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With