4 Answers, 1 is accepted
A way of achieving this is to use EnumDataSource class in your Business Object, as suggested below:
public
EnumDataSource PositionEnum
{
get
{
return
new
EnumDataSource { EnumType =
typeof
(Position) };
}
}
Then you should be able to set the enum values as an ItemsSource of DataFormComboBoxFiled:
<
telerik:DataFormComboBoxField
ItemsSource="{Binding CurrentItem.PositionEnum,
RelativeSource={RelativeSource
AncestorType
=
telerik
:RadDataForm},
Mode
=
OneWay
}">
</
telerik:DataFormComboBoxField
>
You can also check the Binding Enum to DataFormComboBoxField forum thread for further reference.
I hope that this helps.
Best Regards,
Stefan
Telerik
See What's Next in App Development. Register for TelerikNEXT.
Hi Stefan,
I'm trying to achieve the same here; binding a enum value to a DataFormComboBoxField of a DataForm in WPF.
Your ItemSource doesn't seems te work. It's not populating the ComboBox and it's not showing the current value.
What is the correct definition for binding an enum?
From the provided information, I guess that you have binding errors. Can you please check this out? They can be observed in the output window in Visual Studio when debugging the application.
I have also prepared a sample application, demonstrating how the EnumDataSource can be used to populate DataFormComboBoxField.
Hope this helps.
Best Regards,
Stefan X1
Telerik
Hi,
Thank you for your reply.
I've fixed the issue with the following;
<telerik:DataFormComboBoxField
Label="Gender"
DisplayMemberPath="DisplayName"
SelectedValuePath="Value"
ItemsSource="{Binding DataContext.GenderEnum, ElementName=Main, Mode=OneWay}"
DataMemberBinding="{Binding Gender, Mode=TwoWay}" />
GenderEnum is of type EnumDataSource