我正在尝试更改内部的DataGrid项目AutomationProperties名称Item DataGrid,但它从未更改,通常将类名称作为AutomationProperties名称。
XAML中的代码
<DataGrid> <!-- added by edit -->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Path=Name}" ElementStyle="{StaticResource DataGridTextCellStyle}" Header="Name" Width="Auto"/>
<DataGridTextColumn Binding="{Binding Path=Value}" ElementStyle="{StaticResource DataGridTextCellStyle}" Header="Value" Width="Auto">
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell" BasedOn="{StaticResource dgcStyle}">
<Setter Property="ToolTip" Value="{Binding Path=Value, TargetNullValue='No value'}"/>
<Setter Property="AutomationProperties.Name" Value="{Binding Path=Value, TargetNullValue='No value'}"/>
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
</DataGrid.Columns>
<DataGrid.ItemContainerStyle>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="AutomationProperties.Name" Value="{Binding Path=AutomationName}"/>
<Setter Property="Focusable" Value="True"/>
<Setter Property="IsTabStop" Value="False"/>
</Style>
</DataGrid.ItemContainerStyle>
</DataGrid>
如您所见,即使我正在使用,datagrid.itemcontainerstyle但名称仍然类似于类路径“ App.Shared.Models.ItemModel”
相关分类