Click here to Skip to main content
15,912,329 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Data Template Checkbox Binding Question Pin
Wayne Gaylard2-Jan-14 19:21
professionalWayne Gaylard2-Jan-14 19:21 
I assume your model implements INotifyPropertyChanged Interface. In your VM, you can subscribe to the model's property changed event, and then check if the IsChecked property is the one being changed. If the instance of the model is inside a collection (I assume it is as this is a hierarchicaltemplate), you will need to subscribe to the collection's collection changed event, then inside that method, you subscribe to each instance's property changed event.

Something like this

C#
Items.CollectionChanged += ItemsChanged;

private void ItemsCHanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if(e.NewItems != null)
            {
                foreach(Item item in e.NewItems)
                {
                    //Subscribe to property changed
                    item.PropertyChanged += ItemChanged;
                }
            }
            if (e.OldItems != null)
            {
                foreach (Item item in e.OldItems)
                {
                    //Ensure you unsubscribe
                    item.PropertyChanged -= ItemChanged;
                }
            }
        }

        private void ItemChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
           if(e.PropertyName == "IsChecked")
           {
               //Do work here
           }
        }

When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

GeneralRe: Data Template Checkbox Binding Question Pin
Kevin Marois10-Jan-14 10:50
professionalKevin Marois10-Jan-14 10:50 
GeneralRe: Data Template Checkbox Binding Question Pin
Wayne Gaylard11-Jan-14 4:43
professionalWayne Gaylard11-Jan-14 4:43 
QuestionConvert xaml to C# Pin
Member 104997162-Jan-14 6:53
Member 104997162-Jan-14 6:53 
SuggestionRe: Convert xaml to C# Pin
BenScharbach14-Oct-17 9:45
BenScharbach14-Oct-17 9:45 
QuestionWPF DialogService Question Pin
Kevin Marois29-Dec-13 11:31
professionalKevin Marois29-Dec-13 11:31 
AnswerRe: WPF DialogService Question Pin
veboys30-Dec-13 5:08
veboys30-Dec-13 5:08 
GeneralRe: WPF DialogService Question Pin
Kevin Marois30-Dec-13 6:56
professionalKevin Marois30-Dec-13 6:56 
SuggestionRe: WPF DialogService Question Pin
Ron Beyer30-Dec-13 5:39
professionalRon Beyer30-Dec-13 5:39 
GeneralRe: WPF DialogService Question Pin
Kevin Marois30-Dec-13 6:56
professionalKevin Marois30-Dec-13 6:56 
GeneralRe: WPF DialogService Question Pin
Kevin Marois30-Dec-13 7:06
professionalKevin Marois30-Dec-13 7:06 
GeneralRe: WPF DialogService Question Pin
Ron Beyer30-Dec-13 7:22
professionalRon Beyer30-Dec-13 7:22 
GeneralRe: WPF DialogService Question Pin
Kevin Marois30-Dec-13 7:22
professionalKevin Marois30-Dec-13 7:22 
GeneralRe: WPF DialogService Question Pin
Kevin Marois30-Dec-13 7:35
professionalKevin Marois30-Dec-13 7:35 
GeneralRe: WPF DialogService Question Pin
Ron Beyer30-Dec-13 7:46
professionalRon Beyer30-Dec-13 7:46 
GeneralRe: WPF DialogService Question Pin
Kevin Marois30-Dec-13 7:53
professionalKevin Marois30-Dec-13 7:53 
GeneralRe: WPF DialogService Question Pin
Ron Beyer30-Dec-13 8:03
professionalRon Beyer30-Dec-13 8:03 
GeneralRe: WPF DialogService Question Pin
Kevin Marois30-Dec-13 8:08
professionalKevin Marois30-Dec-13 8:08 
GeneralRe: WPF DialogService Question Pin
Kevin Marois30-Dec-13 8:45
professionalKevin Marois30-Dec-13 8:45 
GeneralRe: WPF DialogService Question Pin
Ron Beyer30-Dec-13 8:54
professionalRon Beyer30-Dec-13 8:54 
GeneralRe: WPF DialogService Question Pin
Kevin Marois30-Dec-13 9:18
professionalKevin Marois30-Dec-13 9:18 
GeneralRe: WPF DialogService Question Pin
Ron Beyer30-Dec-13 10:25
professionalRon Beyer30-Dec-13 10:25 
GeneralRe: WPF DialogService Question Pin
Kevin Marois30-Dec-13 10:28
professionalKevin Marois30-Dec-13 10:28 
GeneralRe: WPF DialogService Question Pin
Kevin Marois31-Dec-13 5:54
professionalKevin Marois31-Dec-13 5:54 
GeneralRe: WPF DialogService Question Pin
Ron Beyer31-Dec-13 6:09
professionalRon Beyer31-Dec-13 6:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.