是否可以在DataGridComboBoxColumn.ElementStyle中使用转换器?
你可以在下面看到我把转换器放在Text属性中,即使转换器类运行(我可以调试它),原始文本也会返回。那我做错了什么?
<DataGridComboBoxColumn.ElementStyle>
<Style TargetType="ComboBox">
<Setter Property="ItemsSource"
Value="{Binding DataContext.Collection,
RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType=Window}}"/>
<Setter Property="DisplayMemberPath" Value="Id"/>
<Setter Property="HorizontalAlignment" Value="Center"</Setter>
<Setter Property="Text" Value="{Binding Id, Converter{StaticResource Converter}"></Setter>
</Style>
</DataGridComboBoxColumn.ElementStyle>
由于
答案 0 :(得分:2)
是不是可以正确转换文本但是由于绑定了组合框项目源,显示文本正在使用ID字段,因为DisplayMemberPath已设置,因此文本属性被忽略。