样式
DynamicResource 引用于在根文档定义的资源
比如:App.xaml
或者 Generic.xaml
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
StaticResource 仅限引用于当前文档定义的资源
获取父元素的属性值
<Grid x:Name="Shdw" Background="Red">
<Border
x:Name="DropDownBorder"
Background="{Binding ElementName=Shdw, Path=Background}"
BorderBrush="Red"
BorderThickness="1" />
</Grid>
获取父元素的属性值修改子元素属性值
<ComboBox Grid.Row="8">
<Popup
AllowsTransparency="true"
IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"
Placement="Bottom" />
</ComboBox>
设置具有占位列表属性的样式 ItemContainerStyle
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
<Setter Property="Background" Value="#0c2636" />