如何将enum
with Description
( DescriptionAttribute
) 绑定到 a ComboBox
?
我有一个enum
:
public enum ReportTemplate
{
[Description("Top view")]
TopView,
[Description("Section view")]
SectionView
}
我试过这个:
<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type System:Enum}"
x:Key="ReportTemplateEnum">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="Helpers:ReportTemplate"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<Style x:Key="ReportTemplateCombobox" TargetType="dxe:ComboBoxEditSettings">
<Setter Property="ItemsSource"
Value="{Binding Source={x:Type Helpers:ReportTemplate}}"/>
<Setter Property="DisplayMember" Value="Description"/>
<Setter Property="ValueMember" Value="Value"/>
</Style>
不能成功做到这一点,任何简单的解决方案?
提前致谢!