Binding Ischecked of a checkbox in wpf listbox on selectionchanged of the combobox?

Solution 1: Create a class CategoryViewModel like this.

Up vote 0 down vote favorite share g+ share fb share tw.

I have a combobox of customer and that customer can be in more than 1 categories so I used a listbox which contains check-boxes of all the categories... On the selection change of the customer, the categories in which a particular customer is, should be checked and all the other categories should remain unchecked.. here is my . Dbml file Here is my xaml code of listbox... I think I should use relative source in the binding in Ischecked property of checkbox... But I don't know how to use it please help me out... If there is some other solution to this than do let me know.. Thanks in advance... c# wpf binding checkbox link|improve this question edited Apr 25 '11 at 7:52 asked Apr 25 '11 at 7:19Saral Doshi597 56% accept rate.

Solution 1: Create a class CategoryViewModel like this: class CategoryViewModel : INotifyPropertyChanged { public Category Category {get ... set ...} public bool IsChecked {get ... set ...} //true if Category belongs to currently selected contact } Bind your UI to a ViewModel class that contains a list of CategoryViewModel that gets computed whenever you change the Selected Contact. Basically: class ViewModel : INotifyPropertyChanged { public Contact SelectedContact { get .... set ....} //list of all possible categories (the ones belonging to SelectedContact will have IsChecked true public ObservableCollection Categories { get .... set .... } } Bind your listbox above to ViewModel. Categories property.

SelectedContact should be bound to the currently selected contact. When it changes, in the setter, you re-create Categories list. Solution 2: Use some converters (wouldn't recommend it thought, because it's not MVVM).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions