How to bind RadioButtons to an enum?

I’ve got an enum like this:

public enum MyLovelyEnum
{
    FirstSelection,
    TheOtherSelection,
    YetAnotherOne
};

I got a property in my DataContext:

public MyLovelyEnum VeryLovelyEnum { get; set; }

And I got three RadioButtons in my WPF client.

<RadioButton Margin="3">First Selection</RadioButton>
<RadioButton Margin="3">The Other Selection</RadioButton>
<RadioButton Margin="3">Yet Another one</RadioButton>

Now how do I bind the RadioButtons to the property for a proper two-way binding?

11 Answers
11

Leave a Comment