【发布时间】:2015-07-24 15:58:20
【问题描述】:
所以,我有一个 DataGridComboBoxColumn,它的 itemssource 设置为静态列表。
DatagridComboboxColumn:
<DataGridComboBoxColumn Header="Prioridad" Width="1*" SelectedValueBinding="{Binding SelectedPriorityLevel}"
DisplayMemberPath="Key" SelectedValuePath="Value" ItemsSource="{StaticResource arrList}">
</DataGridComboBoxColumn>
静态资源:
<Window.Resources>
<col:ArrayList x:Key="arrList">
<col:DictionaryEntry Key="A" Value="1"/>
<col:DictionaryEntry Key="M" Value="2"/>
<col:DictionaryEntry Key="B" Value="3"/>
</col:ArrayList>
</Window.Resources>
并且绑定设置为带有枚举的字段
Public Enum ActionPlanPriorityLevels
Alta = 1
Media = 2
Baja = 3
End Enum
我遇到的问题是组合框出于某种原因仅在编辑模式下显示。
但所选值未显示
我错过了什么?
【问题讨论】:
-
我会说它与您绑定到的 SelectedPriorityLevel 属性有关。你能分享一些关于这是什么的代码
-
抱歉,澄清一下,您是希望组合框始终显示还是只希望在编辑后显示所选值?
-
我希望编辑后显示选定的值。 :)
-
那么 SelectedPriorityLevel 是一个具有枚举类型的属性: Public Property SelectedPriorityLevel() As ActionPlanPriorityLevels,Enum ActionPlanPriorityLevels 有 3 个选项,A、M 和 B
-
就是这样。我将属性的类型更改为整数,瞧!现在它可以工作了。非常感谢凯扎。