In the model tier, I have defined an enum:
public enum MemberStatus
{
ActiveMember = 0,
InactiveMember = 1,
Associate = 2,
BoardMember = 3,
Alumni = 4
}
In my view, I have a combo box that is populated with those enum values:
<UserControl.Resources>
<ObjectDataProvider
x:Key="memberStatusesDataProvider"
ObjectType="{x:Type system:Enum}"
MethodName="GetValues">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="model:MemberStatus" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</UserControl.Resources>
...
<ComboBox
ItemsSource="{Binding Source={StaticResource memberStatusesDataProvider}}"
SelectedItem="{Binding Path=Status}" />
...
This results in getting the combo box with the choices that are exactly the same as values defined in the enum. Although that was my initial goal, I want nicer presentation for the user, something like this:
- Combo box choices:
- Active member
- Inactive member
- Associate
- Member of the board
- Alumni
Also, if the language in the application changes, I need the enum values in that language. To tackle this, the first thing that came to my mind is to create a converter for MemberStatus
enum values. I found this beuatiful article on the topic: http://www.codeproject.com/KB/WPF/FriendlyEnums.aspx But MVVM pattern says that there should be no need to create them almost at all - and I agree with this. However, this affirmation does not work in my favor in this example.
How is it supposed to be done? Thanks.