1

我想为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>

所以问题是:如何分别针对垂直拆分器和水平拆分器?

4

2 回答 2

3

用于Style.Triggers有条件地应用设置器。

于 2012-04-15T17:26:26.773 回答
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>
于 2012-04-15T17:35:54.527 回答