Wpf DataGridでは、各行は、残りの領域を埋めるために拡大する空白領域を持っています。私はこの地域をより適切に「ガッター」と呼んでいると想像していますが、実際には適切な用語を知らないのです。私はこれが好きですが、私はそれに問題があることに気付きました。空白領域をクリックすると、行に設定したIsSelected
トリガーを処理していないように見えます。ただし、IsMouseOver
トリガーが発生します。非常に奇妙な。ここで私が言及しているエリアを実証絵です:Wpf DataGrid右 "ガター" IsSelectedトリガー
そして、ここでは、私はこの問題を解決するために必要なことになると思うXAMLのセグメントです。もっと必要な場合は、私に教えてください。私はそれを投稿します。
<!-- Style and template for the DataGridRow. -->
<Style x:Key="VoidwalkerDataGridRowStyle" TargetType="{x:Type DataGridRow}">
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="Validation.ErrorTemplate" Value="{x:Null}" />
<Setter Property="ValidationErrorTemplate">
<Setter.Value>
<ControlTemplate>
<TextBlock
Margin="2,0,0,0"
VerticalAlignment="Center"
Foreground="Red"
Text="!" />
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridRow}">
<Border
x:Name="DGR_Border"
Background="{DynamicResource VoidwalkerContextBrush}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="True">
<SelectiveScrollingGrid>
<SelectiveScrollingGrid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</SelectiveScrollingGrid.ColumnDefinitions>
<SelectiveScrollingGrid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</SelectiveScrollingGrid.RowDefinitions>
<DataGridCellsPresenter
Grid.Column="1"
ItemsPanel="{TemplateBinding ItemsPanel}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<DataGridDetailsPresenter
Grid.Row="1"
Grid.Column="1"
SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
Visibility="{TemplateBinding DetailsVisibility}" />
<DataGridRowHeader
Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="0"
SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
</SelectiveScrollingGrid>
</Border>
<ControlTemplate.Triggers>
<!--
Alternation Coloration Triggers
-->
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Foreground" Value="{DynamicResource VoidwalkerForegroundBrush}" />
<Setter TargetName="DGR_Border" Property="Background" Value="{DynamicResource VoidwalkerContextBrush}" />
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Foreground" Value="{DynamicResource VoidwalkerForegroundBrush}" />
<Setter TargetName="DGR_Border" Property="Background" Value="{DynamicResource VoidwalkerControlBrush}" />
</Trigger>
<!--
Is Selected Triggers
-->
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="DGR_Border" Property="BorderBrush" Value="{DynamicResource VoidwalkerBorderBrush}" />
<Setter TargetName="DGR_Border" Property="Background" Value="{DynamicResource VoidwalkerBorderBrush}" />
</Trigger>
<!--
Is Mouse Over Triggers
-->
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="DGR_Border" Property="BorderBrush" Value="{DynamicResource VoidwalkerBorderBrush}" />
<Setter TargetName="DGR_Border" Property="Background" Value="{DynamicResource VoidwalkerBorderBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
はちょうどさらに私の質問を明確にする:私は絵で「ガター」エリアをクリックすると
を、私のIsSelected
トリガが発生しません。左側のセルをクリックすると、その行が選択されます。奇妙なことは、私の他のIsMouseOver
トリガーは、ガターエリアにマウスをかざすときにまだ発射されているということです。それがある行の溝エリアでIsSelected
の動作をエミュレートできる方法はありますか?