开发者

WPF ListBox as RadioButtonList - mimic SelectionChanging Event via WPF validation

开发者 https://www.devze.com 2022-12-15 22:43 出处:网络
I am using ListBox for having RadioButtonList behaviour (that\'s what people recommend as there is no inherent radio button list in WPF). The listbox is bound to a ViewModel.

I am using ListBox for having RadioButtonList behaviour (that's what people recommend as there is no inherent radio button list in WPF). The listbox is bound to a ViewModel.

Now, whenever user changes the selection on listbox, I want to check whether user has some unsaved data on the part of screen and prompt accordingly (typical yes,no,cancel). If I use SelectionChanged event, the selection has already occured and hence, prompting is of no use. And ther开发者_如何学编程e doesn't seem to be any SelectionChanging event.

I am am not sure but can I mimic SelectionChanging behaviour by using WPF binding validation rules? Or should I use MouseButtonDown event? Would that lead to problems?


You don't need to put them in a listbox, the are group-able like so:

 <RadioButton GroupName=“One“ IsChecked=“True“/> 

Notice the GroupName, this holds the collection together, as for the rest of your question I am having a slight issue understanding what you need, sorry :(

0

精彩评论

暂无评论...
验证码 换一张
取 消