我想为水平与垂直的GridSplitter
设置不同的背景。这是因为我有一个线性渐变,我需要根据网格分割器的对齐方式将其旋转90度。
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type GridSplitter}">
<Setter Property="Background" Value="Red" /> <!-- How to get this red applied to only Vertical for instance? -->
</Style>
</ResourceDictionary>
所以问题是:我如何单独定位垂直分割器和水平分割器?
答案 0 :(得分:3)
使用Style.Triggers
有条件地应用设置器。
答案 1 :(得分:1)
好的,好像我明白了:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type GridSplitter}">
<Style.Triggers>
<Trigger Property="VerticalAlignment" Value="Stretch">
<Setter Property="Background" Value="#F7F7F7" />
</Trigger>
<Trigger Property="HorizontalAlignment" Value="Stretch">
<Setter Property="Background" Value="red" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>