作成日: 2020/12/28 最終更新日: 2020/12/28
文書種別
使用方法
詳細
CanUserSortColumnsプロパティをTrueに設定するとヘッダに表示されるソートのインジケーター(マーク、アイコン)のスタイルを変更するには、Resources内で下記のテンプレートの定義を変更します。
例えば、インジケータの色を変更するには、SortIndicatorStrokeBrushKeyというキーで色を指定することで設定が可能です。
◎サンプルコード(XAML)
例えば、インジケータの色を変更するには、SortIndicatorStrokeBrushKeyというキーで色を指定することで設定が可能です。
◎サンプルコード(XAML)
<!-- 以下の名前空間を追加する必要があります。 --> <!-- xmlns:sg="http://schemas.grapecity.com/windows/spreadgrid/2012" --> <!-- xmlns:system="clr-namespace:System;assembly=mscorlib" --> <!-- xmlns:spp="clr-namespace:GrapeCity.Windows.SpreadGrid.Presenters;assembly=GrapeCity.WPF.SpreadGrid" --> <Window.Resources> <!-- ソートインジケータの色の設定 --> <SolidColorBrush x:Key="SortIndicatorStrokeBrushKey" Color="Red"/> <LinearGradientBrush x:Key="ColumnHeaderBackgroundBrushKey" StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="#FFFFFFFF"/> <GradientStop Color="#FFFFFFFF" Offset="0.4"/> <GradientStop Color="#FFF7F8FA" Offset="0.4"/> <GradientStop Color="#FFF1F2F4" Offset="1"/> </LinearGradientBrush> <SolidColorBrush x:Key="HeaderForegroundBrushKey" Color="#FF000000"/> <LinearGradientBrush x:Key="ColumnHeaderHighlightBackgroundBrushKey" StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="#F2F9FC"/> <GradientStop Color="#F0F8FB" Offset="0.4"/> <GradientStop Color="#E1F1F9" Offset="0.4"/> <GradientStop Color="#D9ECF6" Offset="1"/> </LinearGradientBrush> <SolidColorBrush x:Key="HeaderHighlightForegroundBrushKey" Color="#FF000000"/> <LinearGradientBrush x:Key="ColumnHeaderSelectedBackgroundBrushKey" StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="#E3F7FF"/> <GradientStop Color="#DFF6FF" Offset="0.4"/> <GradientStop Color="#BDEDFF" Offset="0.4"/> <GradientStop Color="#B7E7FB" Offset="1"/> </LinearGradientBrush> <SolidColorBrush x:Key="HeaderSelectedForegroundBrushKey" Color="#FF000000"/> <LinearGradientBrush x:Key="ColumnHeaderHoverBackgroundBrushKey" StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="#E3F7FF"/> <GradientStop Color="#DFF6FF" Offset="0.4"/> <GradientStop Color="#BDEDFF" Offset="0.4"/> <GradientStop Color="#B7E7FB" Offset="1"/> </LinearGradientBrush> <LinearGradientBrush x:Key="ColumnHeaderHighlightHoverBackgroundBrushKey" StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="#E3F7FF"/> <GradientStop Color="#DFF6FF" Offset="0.4"/> <GradientStop Color="#BDEDFF" Offset="0.4"/> <GradientStop Color="#B7E7FB" Offset="1"/> </LinearGradientBrush> <!--ColumnHeaderCellPresenterのスタイル--> <Style TargetType="spp:ColumnHeaderCellPresenter"> <Setter Property="Background" Value="{StaticResource ColumnHeaderBackgroundBrushKey}"/> <Setter Property="Foreground" Value="{StaticResource HeaderForegroundBrushKey}"/> <Setter Property="HighlightBackground" Value="{StaticResource ColumnHeaderHighlightBackgroundBrushKey}"/> <Setter Property="HighlightForeground" Value="{StaticResource HeaderHighlightForegroundBrushKey}"/> <Setter Property="SelectionBackground" Value="{StaticResource ColumnHeaderSelectedBackgroundBrushKey}"/> <Setter Property="SelectionForeground" Value="{StaticResource HeaderSelectedForegroundBrushKey}"/> <Setter Property="MouseOverBackground" Value="{StaticResource ColumnHeaderHoverBackgroundBrushKey}"/> <Setter Property="HighlightMouseOverBackground" Value="{StaticResource ColumnHeaderHighlightHoverBackgroundBrushKey}"/> <Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="IsTabStop" Value="False" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="spp:ColumnHeaderCellPresenter"> <Grid x:Name="Root" Background="{TemplateBinding Background}"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="SelectionStates"> <VisualState x:Name="Unselected"/> <VisualState x:Name="Selected"> <Storyboard> <DoubleAnimation Storyboard.TargetName="PART_SelectionRenderer" Storyboard.TargetProperty="Opacity" Duration="0" To="1"/> </Storyboard> </VisualState> <VisualState x:Name="SelectedUnfocused"> <Storyboard> <DoubleAnimation Storyboard.TargetName="PART_SelectionRenderer" Storyboard.TargetProperty="Opacity" Duration="0" To="1"/> </Storyboard> </VisualState> <VisualState x:Name="Highlighted"> <Storyboard> <DoubleAnimation Storyboard.TargetName="PART_HighlightRenderer" Storyboard.TargetProperty="Opacity" Duration="0" To="1"/> </Storyboard> </VisualState> <VisualState x:Name="HighlightedUnfocused"> <Storyboard> <DoubleAnimation Storyboard.TargetName="PART_HighlightRenderer" Storyboard.TargetProperty="Opacity" Duration="0" To="1"/> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal"/> <VisualState x:Name="MouseOver"> <Storyboard> <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_MouseOverIndicator"/> </Storyboard> </VisualState> <VisualState x:Name="HighlightedHover"> <Storyboard> <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_MouseOverIndicator"/> </Storyboard> </VisualState> <VisualState x:Name="Disabled"> <Storyboard> <DoubleAnimation Duration="0" To=".55" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_Container"/> <DoubleAnimation Duration="0" To=".55" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="SortFilterPanel"/> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="SortStates"> <VisualState x:Name="Asscend"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SortPathContainer" Storyboard.TargetProperty="Visibility" Duration="0"> <DiscreteObjectKeyFrame KeyTime="0:0:0"> <DiscreteObjectKeyFrame.Value> <Visibility>Visible</Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="Descend"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SortPathContainer" Storyboard.TargetProperty="Visibility" Duration="0"> <DiscreteObjectKeyFrame KeyTime="0:0:0"> <DiscreteObjectKeyFrame.Value> <Visibility>Visible</Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> <DoubleAnimation Duration="0" Storyboard.TargetName="SortPath" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" To="-1"/> <DoubleAnimation Duration="0" Storyboard.TargetName="SortPath" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" To="-1"/> </Storyboard> </VisualState> <VisualState x:Name="NoSort"/> </VisualStateGroup> <VisualStateGroup x:Name="FilterStates"> <VisualState x:Name="NoFilter"/> <VisualState x:Name="HasFilter"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_FilterButton" Storyboard.TargetProperty="HasFilter" Duration="0"> <DiscreteObjectKeyFrame KeyTime="0:0:0"> <DiscreteObjectKeyFrame.Value> <system:Boolean>True</system:Boolean> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="LockedStates"> <VisualState x:Name="ColumnLocked"> <Storyboard> <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="LockedElement"> <DiscreteObjectKeyFrame KeyTime="0"> <DiscreteObjectKeyFrame.Value> <Visibility>Visible</Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="ColumnUnlocked"/> </VisualStateGroup> <VisualStateGroup x:Name="VisibleStates"> <VisualState x:Name="ColumnInvisible"> <Storyboard> <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="InVisibleElement"> <DiscreteObjectKeyFrame KeyTime="0"> <DiscreteObjectKeyFrame.Value> <Visibility>Visible</Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="ColumnVisible"/> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Grid.RowDefinitions> <RowDefinition/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Popup x:Name="PART_Popup" Grid.ColumnSpan="2" > </Popup> <spp:CellSelectionPresenter x:Name="PART_SelectionRenderer" Grid.ColumnSpan="2" Fill="{TemplateBinding ActualSelectionBackground}" Opacity="0"/> <spp:CellSelectionPresenter x:Name="PART_HighlightRenderer" Grid.ColumnSpan="2" Fill="{TemplateBinding ActualSelectionBackground}" Opacity="0" /> <Rectangle x:Name="PART_MouseOverIndicator" Grid.ColumnSpan="2" Fill="{TemplateBinding ActualMouseOverBackground}" IsHitTestVisible="False" Grid.RowSpan="2" Opacity="0"/> <spp:CellElementContainer x:Name="PART_Container" Grid.Column="0" Margin="{TemplateBinding Padding}" Foreground="{TemplateBinding Foreground}" ClipToBounds="True" /> <Grid Grid.Column="1" x:Name="SortFilterPanel"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Grid x:Name="PART_CanSortIndicatorContainer" Visibility="Collapsed"> </Grid> <Grid x:Name="SortIndicatorContainer" Grid.Column="1" Visibility="{TemplateBinding SortIndicatorVisibility}"> <Grid x:Name="SortPathContainer" Visibility="Collapsed"> <Path x:Name="SortPath" Margin="0,0,4,0" Grid.Column="1" Height="8" Width="10" Fill="{StaticResource SortIndicatorStrokeBrushKey}" HorizontalAlignment="Right" Stretch="Uniform" Opacity="1" Data="F1 M -5.215,6.099L 5.215,6.099L 0,0L -5.215,6.099 Z " RenderTransformOrigin="0.5,0.5"> <Path.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform/> <TranslateTransform/> </TransformGroup> </Path.RenderTransform> </Path> </Grid> </Grid> <Grid x:Name="FilterButtonContainer" Grid.Column="2" Margin="0,0,5,0" Visibility="{TemplateBinding FilterButtonVisibility}"> <spp:FilterButton x:Name="PART_FilterButton"> </spp:FilterButton> </Grid> </Grid> <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top"> <Border x:Name="LockedElement" ToolTipService.ToolTip="Column is locked" Width="7" Height="8" Visibility="Collapsed" Margin="2,0,0,0" IsHitTestVisible="False"> <Path x:Name="Lock" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF555555" Data="M 5.50003,14.8333C 5.5,11.0306 5.5,7.22794 7.16663,4.59525C 8.83328,1.96262 12.1667,0.500031 15.6666,0.500031C 19.1666,0.500092 22.8332,1.96268 24.6665,4.59531C 26.4998,7.228 26.4999,11.0307 26.5,14.8333M 0.5,15.8334L 31.5,15.8334L 31.5,38.8333L 0.5,38.8333L 0.5,15.8334 Z "> <Path.Fill> <LinearGradientBrush StartPoint="0.453267,-0.0148371" EndPoint="0.453267,0.976467"> <LinearGradientBrush.GradientStops> <GradientStop Color="#00FFFFFF" Offset="0"/> <GradientStop Color="#00CACACA" Offset="0.390184"/> <GradientStop Color="#00959595" Offset="0.390476"/> <GradientStop Color="#49CACACA" Offset="0.390482"/> <GradientStop Color="#91FFFFFF" Offset="0.400002"/> <GradientStop Color="#A6F7F7F7" Offset="1"/> </LinearGradientBrush.GradientStops> </LinearGradientBrush> </Path.Fill> </Path> </Border> <Border x:Name="InVisibleElement" ToolTipService.ToolTip="Column is hidden" Width="10" Height="8" Visibility="Collapsed" Margin="2,0,0,0"> <Path x:Name="Eye" Stretch="Fill" StrokeLineJoin="Round" Fill="#85FFFFFF" Stroke="#444444" Data="M 19,0.5C 22.6718,0.5 27.2968,4.5 31.0038,7.50003C 34.7108,10.5 37.5,12.5 37.5,12.5C 37.5,12.5 35.0401,14.1802 31.6553,17.0073C 27.8779,20.1621 22.9485,24.5 19,24.5C 15.3282,24.5 10.7031,20.5 6.99609,17.5C 3.28906,14.5 0.5,12.5 0.5,12.5C 0.5,12.5 3.3688,10.5001 7.11578,7.50009C 10.8627,4.50012 15.4878,0.5 19,0.5 Z M 19.1248,11.4419C 21.8172,11.4419 22.4999,11.5193 22.4999,12.4167C 22.4999,13.3141 21.8173,13.3916 19.1249,13.3916C 16.4326,13.3916 16.4999,13.3141 16.4999,12.4168C 16.4999,11.5194 16.4326,11.4419 19.1248,11.4419 Z "/> </Border> </StackPanel> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </Window.Resources>
旧文書番号
86301