作成日: 2020/12/28 最終更新日: 2020/12/28
文書種別
技術情報
詳細
ShowRowSelectorプロパティをTrueに設定すると行ヘッダに表示される行セレクタ(インジケーター、マーク、アイコン)のスタイルを変更するには、Resources内で下記のテンプレートの定義を変更します。
例えば、行セレクタの色を変更するには、GlyphBrushというキーで色を指定することで設定が可能です。
◎サンプルコード(XAML)
例えば、行セレクタの色を変更するには、GlyphBrushというキーで色を指定することで設定が可能です。
◎サンプルコード(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="GlyphBrush" Color="Red" /> <Style x:Key="{x:Type spp:RowHeaderCellPresenter}" TargetType="{x:Type spp:RowHeaderCellPresenter}"> <Setter Property="Background" Value="{DynamicResource RowHeaderBackgroundBrushKey}"/> <Setter Property="Foreground" Value="{DynamicResource HeaderForegroundBrushKey}"/> <Setter Property="spp:BaseCellPresenter.HighlightBackground" Value="{DynamicResource RowHeaderHighlightBackgroundBrushKey}"/> <Setter Property="spp:BaseCellPresenter.HighlightForeground" Value="{DynamicResource HeaderHighlightForegroundBrushKey}"/> <Setter Property="spp:BaseCellPresenter.SelectionBackground" Value="{DynamicResource RowHeaderSelectedBackgroundBrushKey}"/> <Setter Property="spp:BaseCellPresenter.SelectionForeground" Value="{DynamicResource HeaderSelectedForegroundBrushKey}"/> <Setter Property="spp:BaseCellPresenter.MouseOverBackground" Value="{DynamicResource RowHeaderHoverBackgroundBrushKey}"/> <Setter Property="spp:BaseCellPresenter.HighlightMouseOverBackground" Value="{DynamicResource RowHeaderHighlightHoverBackgroundBrushKey}"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="IsTabStop" Value="False"/> <Setter Property="spp:BaseCellPresenter.HeaderSelectionFontWeight" Value="{DynamicResource HeaderSelectionFontWeightKey}"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type spp:RowHeaderCellPresenter}"> <Grid Name="Root" Background="{TemplateBinding Background}"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="SelectionStates"> <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> <VisualState x:Name="Unselected"/> </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"/> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="RowStates"> <VisualState x:Name="CurrentRow"> <Storyboard> <DoubleAnimation Storyboard.TargetName="IsCurrentIndicator" Storyboard.TargetProperty="Opacity" Duration="0" To="1"/> </Storyboard> </VisualState> <VisualState x:Name="NormalRow"/> </VisualStateGroup> <VisualStateGroup x:Name="ValidationStates"> <VisualState x:Name="Valid"/> <VisualState x:Name="Invalid"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="Path"> <DiscreteObjectKeyFrame KeyTime="0"> <ObjectKeyFrame.Value> <SolidColorBrush Color="#FF0000"/> </ObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="ValidationErrorElement"> <DiscreteObjectKeyFrame KeyTime="0"> <ObjectKeyFrame.Value> <Visibility>Visible</Visibility> </ObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="LockedStates"> <VisualState x:Name="RowLocked"> <Storyboard> <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="LockedElement"> <DiscreteObjectKeyFrame KeyTime="0"> <ObjectKeyFrame.Value> <Visibility>Visible</Visibility> </ObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="RowUnlocked"/> </VisualStateGroup> <VisualStateGroup x:Name="VisibleStates"> <VisualState x:Name="RowInvisible"> <Storyboard> <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="InVisibleElement"> <DiscreteObjectKeyFrame KeyTime="0"> <ObjectKeyFrame.Value> <Visibility>Visible</Visibility> </ObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="RowVisible"/> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition /> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition /> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <spp:CellSelectionPresenter x:Name="PART_SelectionRenderer" Grid.ColumnSpan="3" Grid.RowSpan="3" Fill="{TemplateBinding ActualSelectionBackground}" Opacity="0"/> <spp:CellSelectionPresenter x:Name="PART_HighlightRenderer" Grid.ColumnSpan="3" Grid.RowSpan="3" Fill="{TemplateBinding ActualSelectionBackground}" Opacity="0"/> <Rectangle Name="PART_MouseOverIndicator" Grid.ColumnSpan="2" Fill="{TemplateBinding ActualMouseOverBackground}" IsHitTestVisible="False" Grid.RowSpan="2" Opacity="0"/> <spp:CellElementContainer x:Name="PART_Container" Grid.Row="1" Grid.Column="1" Margin="{TemplateBinding Padding}" Foreground="{TemplateBinding Foreground}" ClipToBounds="True"/> <Border Name="IsCurrentIndicator" Opacity="0" Visibility="{TemplateBinding RowSelectorVisibility}" Width="9" Height="14" Grid.Column="0" Grid.Row="1"> <Path Name="Path" Width="5" Height="10" Canvas.Left="0" HorizontalAlignment="Right" VerticalAlignment="Center" Canvas.Top="0" Stretch="Fill" Data="F1 M5,5 L0,0 L0,10 L5,5" Fill="{StaticResource GlyphBrush}"/> </Border> <Grid Height="13" Width="13" Margin="0" HorizontalAlignment="Left" Column="1" Row="1" Visibility="{TemplateBinding ValidationIndicatorVisibility}"> <Ellipse Margin="0" RenderTransformOrigin="0.5,0.5"> <Shape.Stroke> <LinearGradientBrush StartPoint="0.505,0.65" EndPoint="0.5,0.058"> <GradientStop Color="#FFCA000C" Offset="0"/> <GradientStop Color="#FFFF9298" Offset="0.991"/> </LinearGradientBrush> </Shape.Stroke> <Shape.Fill> <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> <GradientStop Color="#FFFFFFFF" Offset="0"/> <GradientStop Color="#FFFDC8C8" Offset="1"/> </LinearGradientBrush> </Shape.Fill> </Ellipse> <Path Fill="#DDD43940" Data="M5.5,2.5 L7.5,2.5 L7.5,8 L5.5,8 M5.5,9.5 L7.5,9.5 L7.5,10.5 L5.5,10.5"/> </Grid> <Rectangle Name="ValidationErrorElement" Fill="#00FFFFFF" Grid.RowSpan="3" Grid.ColumnSpan="3" Visibility="Collapsed"> <ToolTipService.ToolTip> <ToolTip Name="validationTooltip" Margin="-2,0,0,0" Padding="0" Template="{DynamicResource ValidationToolTipTemplate}" DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}"> <spp:SpreadValidationSummary ItemsSource="{TemplateBinding ValidationErrors}"/> </ToolTip> </ToolTipService.ToolTip> </Rectangle> <StackPanel Orientation="Horizontal" Grid.RowSpan="3" Grid.ColumnSpan="3" HorizontalAlignment="Left" VerticalAlignment="Top" IsHitTestVisible="False"> <Border Name="LockedElement" ToolTipService.ToolTip="Row is locked" Width="7" Height="8" Visibility="Collapsed" Margin="2,0,0,0"> <Path Name="Lock" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF555555" Data="M5.50003,14.8333 C5.5,11.0306 5.5,7.22794 7.16663,4.59525 C8.83328,1.96262 12.1667,0.500031 15.6666,0.500031 C19.1666,0.500092 22.8332,1.96268 24.6665,4.59531 C26.4998,7.228 26.4999,11.0307 26.5,14.8333 M0.5,15.8334 L31.5,15.8334 L31.5,38.8333 L0.5,38.8333 L0.5,15.8334"> <Shape.Fill> <LinearGradientBrush StartPoint="0.453267,-0.0148371" EndPoint="0.453267,0.976467"> <GradientBrush.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"/> </GradientBrush.GradientStops> </LinearGradientBrush> </Shape.Fill> </Path> </Border> <Border Name="InVisibleElement" ToolTipService.ToolTip="Row is hidden" Width="10" Height="8" Visibility="Collapsed" Margin="2,0,0,0"> <Path Name="Eye" Stretch="Fill" StrokeLineJoin="Round" Fill="#85FFFFFF" Stroke="#444444" Data="M19,0.5 C22.6718,0.5 27.2968,4.5 31.0038,7.50003 C34.7108,10.5 37.5,12.5 37.5,12.5 C37.5,12.5 35.0401,14.1802 31.6553,17.0073 C27.8779,20.1621 22.9485,24.5 19,24.5 C15.3282,24.5 10.7031,20.5 6.99609,17.5 C3.28906,14.5 0.5,12.5 0.5,12.5 C0.5,12.5 3.3688,10.5001 7.11578,7.50009 C10.8627,4.50012 15.4878,0.5 19,0.5 M19.1248,11.4419 C21.8172,11.4419 22.4999,11.5193 22.4999,12.4167 C22.4999,13.3141 21.8173,13.3916 19.1249,13.3916 C16.4326,13.3916 16.4999,13.3141 16.4999,12.4168 C16.4999,11.5194 16.4326,11.4419 19.1248,11.4419"/> </Border> </StackPanel> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </Window.Resources>
旧文書番号
86311