I had data binding like this:
ItemsSource="{Binding Source={my:Enumeration {x:Type credit:OccupationCategory}}}"
DisplayMemberPath="Description"
SelectedValue="{Binding EmplType}"
SelectedValuePath="Value"/>
and it worked very well. Make a larger software change, I can no longer have anything that generates an INotifyPropertyChanged event so that the data binding type does not work. Instead, I manually install selectedIndex and build the parameters from the code as follows:
ItemsSource="{Binding Source={StaticResource ResidenceOwnershipType}}"/>
which refers to
<UserControl.Resources>
<ObjectDataProvider x:Key="ResidenceOwnershipType" MethodName="GetValues" ObjectType="{x:Type System:Enum}" >
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="credit:ResidenceOwnershipType" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</UserControl.Resources>
This works in terms of creating list parameters and linking all my data, but I can't get comboboxes to show the description tag in an enumeration instead of the actual text.
I tried something like this:
DisplayMemberPath="Description"
but it was wrong. How should I do it?
EDIT:
My enum:
[DataContract]
public enum ResidenceOwnershipType
{
[Description("")]
None = 0,
[Description("Owns Home Outright")]
OwnsHomeOutright = 1,
[Description("Buying Home")]
BuyingHome = 2,
[Description("Renting/Leasing")]
RentingLeasing = 4,
[Description("Living w/Relatives")]
LivingWithRelatives = 3,
[Description("Owns/Buying Mobile Home")]
MobileHome = 5,
[Description("Unknown")]
Unknown = 6
}
source
share