1
我在嘗試ScrollIntoView的DataGrid並突出顯示另一種顏色的特定行和列。 ScrollIntoView適用於跳到正確的位置。亮點不是。以下是我使用跳轉到位置:在DataGrid中突出顯示SelectedItem的行
public void ShowSelection(int row, int column)
{
dtGridReads.SelectedItem = dtGridReads.Items[row];
dtGridReads.SelectedItem = dtGridReads.Columns[column];
dtGridReads.UpdateLayout();
dtGridReads.ScrollIntoView(dtGridReads.Items[row], dtGridReads.Columns[column]);
}
這裏是我的WPF的DataGrid:
<DataGrid x:Name="dtGridReads" AutoGenerateColumns="False"
VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.VirtualizationMode ="Standard"
EnableColumnVirtualization="True"
EnableRowVirtualization="True"
ScrollViewer.IsDeferredScrollingEnabled="True"
CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserSortColumns="True"
ItemsSource ="{Binding}" Block.TextAlignment="Center"
CanUserAddRows="False" CanUserDeleteRows="False" FrozenColumnCount="1"
GridLinesVisibility="None" Style="{StaticResource DataGridStyle_Blue}" ScrollViewer.ScrollChanged="dtGridReads_ScrollChanged">
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsSelected}" Value="True">
<Setter Property="Background" Value="Red" />
</DataTrigger >
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
</DataGrid>
感謝。
有沒有辦法來添加列突出呢?既然ScrollIntoView也這樣做?謝謝。 – Crystal