WPF MVVM Radio buttons on ItemsControl

前端 未结 4 743
予麋鹿
予麋鹿 2020-12-08 11:08

I\'ve bound enums to radio buttons before, and I generally understand how it works. I used the alternate implementation from this question: How to bind RadioButtons to an e

4条回答
  •  清歌不尽
    2020-12-08 11:38

    It turns out that it is much simpler to abandon using ItemsControl and instead go with ListBox.

    It may be more heavy-weight, but that's mostly because it is doing the heavy lifting for you. It is really easy to do a two-way binding between RadioButton.IsChecked and ListBoxItem.IsSelected. With the proper control template for the ListBoxItem, you can easily get rid of all the selection visual.

    
        
            
            
        
        
            
                
                    
                    
                        
                    
                
            
        
    
    

提交回复
热议问题