문제

What is the best way of binding a number of RadioButtons to an enum using MVVM?

The only way I can think of is binding each group box's IsChecked to a property, and in the setter of that property assign a value to an enum in the view model.

도움이 되었습니까?

해결책

You could display the Enum values in a ListBox and provide a special ItemTemplate with a RadioButton plus the name of the Enum. The RadioButton's IsChecked property could then be bound to the ListBoxItem's IsSelected property. Of course, you would have to set the ListBox's SelectionMode to Single.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top