![](/img/trans.png)
[英]codebehind binding of DataGridComboboxColumn in wpf datagrid
[英]WPF DataGrid using convert on DataGridComboBoxColumn
是否可以在DataGridComboBoxColumn.ElementStyle內使用轉換器?
您可以在下面看到我已將Converter放在Text屬性內,即使Converter類確實運行了(我可以調試它),也返回了原始文本。 那我在做什么錯呢?
<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>
謝謝
是否不是可以正確轉換文本的情況,而是因為組合框項目源已綁定,所以由於設置了DisplayMemberPath,因此顯示文本正在使用ID字段,因此忽略了text屬性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.