MVVM Group Radio Button

偶尔善良 提交于 2019-12-11 12:21:06

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/2713411/mvvm-group-radio-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!