本文介绍了DataGridComboBoxColumn细胞不显示所选项目的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何得到DataGridComboBoxColumn显示所选项目的文本时,它是不是在编辑模式?而且也有可能使它所以在编辑模式组合框中显示所选项的文本开始?
下面是我的XAML:
< DataGridComboBoxColumn标题=格式化
SelectedItemBinding ={绑定路径=格式}>
< DataGridComboBoxColumn.ElementStyle>
<风格的TargetType =>
< setter属性=文字值={绑定路径= FormatView.Name}/>
< /样式和GT;
< /DataGridComboBoxColumn.ElementStyle>
< DataGridComboBoxColumn.EditingElementStyle>
<风格的TargetType =组合框>
< setter属性=的ItemsSourceVALUE ={绑定路径= DefinedFormatters}/>
< setter属性=IsDropDownOpenVALUE =真/>
< setter属性=ItemTemplate中>
< Setter.Value>
<的DataTemplate>
< TextBlock的文本={绑定路径=名称}>< / TextBlock的>
< / DataTemplate中>
< /Setter.Value>
< /二传手>
< /样式和GT;
< /DataGridComboBoxColumn.EditingElementStyle>
< / DataGridComboBoxColumn>
解决方案
这是我发现的有用的DataGridComboBoxColumn唯一的资源:
的
其他的一切(我发现在非MSDN网站)中的误导性!
I was wondering how you get the DataGridComboBoxColumn to display the selected item text when it is not in editing mode? And also is it possible to make it so the combo box in edit mode displays the selected item text initially?
Here is my XAML:
<DataGridComboBoxColumn Header="Formatter"
SelectedItemBinding="{Binding Path=Format}">
<DataGridComboBoxColumn.ElementStyle>
<Style TargetType="">
<Setter Property="Text" Value="{Binding Path=FormatView.Name}" />
</Style>
</DataGridComboBoxColumn.ElementStyle>
<DataGridComboBoxColumn.EditingElementStyle>
<Style TargetType="ComboBox">
<Setter Property="ItemsSource" Value="{Binding Path=DefinedFormatters}" />
<Setter Property="IsDropDownOpen" Value="True" />
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding Path=Name}"></TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</DataGridComboBoxColumn.EditingElementStyle>
</DataGridComboBoxColumn>
解决方案
This was the only resource on DataGridComboBoxColumn that I found helpful:
http://msdn.microsoft.com/en-us/library/system.windows.controls.datagridcomboboxcolumn.aspx
Everything else (that I found on non-MSDN sites) was misleading!
这篇关于DataGridComboBoxColumn细胞不显示所选项目的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!