1. Name选择器
<Window.Styles>
<Style Selector="Button#test" >
<Setter Property="Background" Value="Orange" ></Setter>
</Style>
</Window.Styles>
<Button Grid.Row="7" x:Name="test1">test1</Button>
<Button Grid.Row="8" Name="test2">test2</Button>
2.Class选择器
<Button Grid.Row="7" Classes="Test2">dfudbhuidf</Button>
<Style Selector="Button.Test2">
<Setter Property="BorderBrush" Value="Blue"></Setter>
</Style>
Classes的值可以有多个;且可以增加条件,比如:
<Button Grid.Row="7" Classes="Test2 Test3">dfudbhuidf</Button>
<Style Selector="Button.Test2.Test3">
<Setter Property="BorderBrush" Value="Blue"></Setter>
</Style>
3.Or选择器
<Style Selector="TextBlock, Button">