XAML-DataGridComboBoxColumn中ComboBox元素的自动化ID [英] XAML - Automation ID for ComboBox elements in DataGridComboBoxColumn
问题描述
首先,我用于自动化ComboBox的各个元素的方法如下:
To start off, the method that I'm using for automating individual elements of ComboBox is as follows:
<ComboBox.ItemContainerStyle>
<Style TargetType="ComboBoxItem">
<Setter Property="AutomationProperties.AutomationId"
Value="{Binding ProviderName}" />
</Style>
</ComboBox.ItemContainerStyle>
ProviderName
绑定到ComboBox的DisplayMemberPath
属性.
ProviderName
is bound to the ComboBox's DisplayMemberPath
property.
我的问题是,尝试修改DataGridComboBoxColumn
时ItemContainerStyle
似乎不可用,因此其中包含的组合框的元素也具有自动化ID.
My problem is that ItemContainerStyle
does not seem to be available when trying to modify DataGridComboBoxColumn
so that the elements of the combo box contained within also have automation IDs.
有人遇到过这样做的方法吗?
Has anyone come across a method for doing so?
我仍在研究不同的想法,因此,如果遇到任何有意义的结果,都将其发布.预先感谢.
I'm still toying around with different ideas, so if I come across any meaningful results I'll post them. Thanks in advance.
推荐答案
经过一些试验,我设法通过设置EditingElementStyle
使它正常工作.
After some experimenting, I managed to get it to work by setting the EditingElementStyle
.
这是XAML:
<DataGridComboBoxColumn.EditingElementStyle>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="ComboBoxItem">
<Setter Property="AutomationProperties.AutomationId"
Value="{Binding ProviderName}" />
</Style>
</Setter.Value>
</Setter>
</Style>
</DataGridComboBoxColumn.EditingElementStyle>
这篇关于XAML-DataGridComboBoxColumn中ComboBox元素的自动化ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!