1

如何在 wpf 数据网格标题中显示自定义排序方向图像?

我在我的数据网格中使用这种风格。如何为升序和降序排序方向添加图像?

<Style x:Key="DataGridColumnHeaderStyle" TargetType="{x:Type DataGridColumnHeader}"  >
        <Setter Property="Background">
            <Setter.Value>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Color="#fbfdfc" Offset="0.1" />
                    <GradientStop Color="#d4d5d9" Offset="0.9" />
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Foreground" Value="Black" />
        <Setter Property="Padding" Value="3"/>
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" />
                    <Condition Property="SortDirection" Value="{x:Null}" />
                </MultiTrigger.Conditions>
                <Setter Property="Background">
                    <Setter.Value>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="#ffd8a8" Offset="0.0" />
                            <GradientStop Color="#ffad41" Offset="0.5" />
                            <GradientStop Color="#fedf78" Offset="0.9" />
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Setter Property="BorderBrush" Value="Black" />
            </MultiTrigger>
        </Style.Triggers>
    </Style>
4

1 回答 1

2

如果要更改需要覆盖的三角形Template,可以触发SortDirection并相应地显示不同的图像。(从 MSDN获取默认模板(Default WPF Themes链接))

于 2011-08-30T08:15:08.617 回答