作成日: 2026/06/24 最終更新日: 2026/06/24
文書種別
使用方法
詳細
CanUserFilterColumnsプロパティをTrueに設定するとヘッダに表示されるフィルタのインジケーター(マーク、アイコン)のスタイルを変更するには、下記のテンプレートを変更します。
例えば、下記は、インジケータの色を変更するには、FilterIndicatorPathという名称で示されるオブジェクトのStrokeプロパティで指定することが可能です。
◎サンプルコード(XAML)
例えば、下記は、インジケータの色を変更するには、FilterIndicatorPathという名称で示されるオブジェクトのStrokeプロパティで指定することが可能です。
◎サンプルコード(XAML)
<!-- 以下の名前空間を追加する必要があります。 -->
<!-- xmlns:sg="http://schemas.grapecity.com/windows/spreadgrid/2012" -->
<!-- xmlns:spp="clr-namespace:GrapeCity.Windows.SpreadGrid.Presenters;assembly=GrapeCity.WPF.SpreadGrid" -->
<Window.Resources>
<Style TargetType="spp:FilterButton">
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="spp:FilterButton">
<Grid Background="{TemplateBinding Background}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="FilterStates">
<VisualState x:Name="HasFilter">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="FilterIndicatorPath" Storyboard.TargetProperty="Fill" Duration="0">
<DiscreteObjectKeyFrame KeyTime="0:0:0">
<DiscreteObjectKeyFrame.Value>
<LinearGradientBrush StartPoint="-0.328067,0.00404512" EndPoint="1.28461,0.00404512">
<LinearGradientBrush.RelativeTransform>
<TransformGroup>
<SkewTransform CenterX="-0.328067" CenterY="0.00404512" AngleX="-1.9556" AngleY="0"/>
<RotateTransform CenterX="-0.328067" CenterY="0.00404512" Angle="10.9488"/>
</TransformGroup>
</LinearGradientBrush.RelativeTransform>
<LinearGradientBrush.GradientStops>
<GradientStop Color="#D3D3D3" Offset="0.0333333"/>
<GradientStop Color="#DADADA" Offset="0.238095"/>
<GradientStop Color="#A9A9A9" Offset="0.52619"/>
<GradientStop Color="#5E7981" Offset="0.752381"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="NoFilter"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<!-- Strokeプロパティの変更でフィルタマークの色を変更できます -->
<Path x:Name="FilterIndicatorPath" Grid.Column="1" StrokeLineJoin="Round" Width="13" Height="12" Stretch="Fill" Stroke="#A8DAF5"
Data="F1 M 0.5,0.5L 14.5001,0.559174L 14.5,1.55914L 8.5,7.55914L 8.5,13.5592L 7.5,13.5592L 6.50006,11.5592L 6.50006,7.55914L 0.5,1.55914L 0.5,0.5 Z "/>
<ContentPresenter Content="{TemplateBinding Content}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>