/// <summary> /// Updates the selected collection whenever an object is set to selected. /// </summary> /// <param name="args"></param> public void SyncSelectedItem(ChildElementPropertyChangedEventArgs args) { var item = args.ChildElement as LItem; if (item != null && args.PropertyName.ToString() == "IsSelected") { var match = _selectedItems.FirstOrDefault(i => i.Id == item.Id); if (match != null) { if (!item.IsSelected) { // Remove _selectedItems.Remove(match); Logger.LogVerbose("Removed {0} ({2}) from Selected Items, NewSelectedCount={1}", item.Name, _selectedItems.Count, item.Id); } else { // Update Data } } else if (match == null && item.IsSelected) { _selectedItems.Add(item); Logger.LogVerbose("Added {0} ({2}) to Selected Items, NewSelectedCount={1}", item.Name, _selectedItems.Count, item.Id); } } }
/// <summary> /// This method will raise an event when a property change event /// occurs in a child element. The source element is supplied /// in the event arguments. A protected member is accessible from /// within the class in which it is declared, and from within any /// class derived from the class that declared this member. /// The implementation of a virtual member can be changed by an /// overriding member in a derived class.When a virtual method is /// invoked, the run-time type of the object is checked for an /// overriding member. The overriding member in the most derived /// class is called, which might be the original member, if no /// derived class has overridden the member. /// </summary> /// <param name="sender">The original source of the event.</param> /// <param name="e">The arguments for the event.</param> protected virtual void OnChildElementPropertyChanged(object sender, ChildElementPropertyChangedEventArgs e) { //If there is something listening for the event. if (ChildElementPropertyChanged != null) { //Raise the event. ChildElementPropertyChanged(sender, e); } }