我尝试更改DataGrid
内的AutomationProperties
项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
,但名称仍然类似于路径&#34; App.Shared.Models.ItemModel&#34;
答案 0 :(得分:0)