私はデータグリッドを持っていて、VirtualizingStackPanel.IsVirtualizing = true と VirtualizingStackPanel.VirtualizationMode = Standard を持っています。いくつかの条件に従って、データグリッドのrowHeaderの一部に小さなアイコンを1つ表示したい
私の問題は、正しい行数が得られますが、表示されている行ヘッダーにのみアイコンが表示されることです。下にスクロールすると、他の行にアイコンが表示されません。例: 100 行から、50 行にアイコンがオンになっていても、上下にスクロールせずに表示できる行にのみアイコンが表示されます。
以下のコードを使用してアイコンを表示しています
foreach (DataRow eRow in ((DataView)rgrid.ItemsSource).Table.Rows())
{
int rowIndex = ((DataView)rgrid.ItemsSource).Table.Rows.IndexOf(eRow);
DataGridRow eGridRow = DataGridHelper.GetRow(rgrid, rowIndex);
DataGridRowHeader rowHeader = DataGridHelper.FindVisualChild<DataGridRowHeader>(eGridRow);
if (rowHeader != null)
{
if (----condition----)
{
rowHeader.SetValue(DataGridProperties.DisplayIconProperty, true);
}
}
}
RowHeader テンプレートの XAML コード
<ControlTemplate TargetType="{x:Type DataGridRowHeader}" x:Key="RowHeaderControlTemplateNoMouseOver">
<Grid Background="{TemplateBinding Background}" x:Name="dgRowHeader">
<ContentPresenter x:Name="content" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,6,0,0" Content="{TemplateBinding Content}" Height="20" />
<Grid Grid.Column="0" x:Name="errorIconNoMouseOver" HorizontalAlignment="Right" VerticalAlignment="Bottom" Visibility="Collapsed">
<Image Source="../../Resources/Images/warningimage_small.png" Margin="0,0,3,3" Width="16"></Image>
</Grid>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="prism:DataGridProperties.DisplayIcon" Value="True">
<Setter TargetName="errorIconNoMouseOver" Property="Visibility" Value="Visible" />
</Trigger>
</ControlTemplate.Triggers>
PLSヘルプ。
ありがとう
ディー