Click here to Skip to main content
15,908,909 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Handle DataGrid Row Model Property Change Pin
Pete O'Hanlon22-Jun-17 5:03
mvePete O'Hanlon22-Jun-17 5:03 
It's fairly straightforward to do. Hook up to the CollectionChanged event handler from your ObservableCollection and then, whenever the collection changes, you add or remove event handlers. The event handling looks a bit like this:
C#
private void HandleCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
  if (e.OldItems != null)
  {
    foreach (object item in e.OldItems)
    {
      ((INotifyPropertyChanged)item).PropertyChanged -= MyPropertyChangedHandler;
    }
  }
  if (e.NewItems != null)
  {
    foreach (object item in e.NewItems)
    {
      ((INotifyPropertyChanged)item).PropertyChanged += MyPropertyChangedHandler;
    }
  }
}
This means, whenever you add or remove an item to your collection, you now have the ability to hook into the models INPC chain. This might look a bit like this:
C#
private void MyPropertyChangedHandler(object sender, PropertyChangedEventArgs e)
{
  if (e.PropertyName != "Name") return;
  MyModel model = sender as MyModel;
  Debug.WriteLine($"Name changed to {model.Name}");
}

This space for rent

GeneralRe: Handle DataGrid Row Model Property Change Pin
Mycroft Holmes22-Jun-17 14:41
professionalMycroft Holmes22-Jun-17 14:41 
GeneralRe: Handle DataGrid Row Model Property Change Pin
Pete O'Hanlon22-Jun-17 21:18
mvePete O'Hanlon22-Jun-17 21:18 
GeneralStop user from killing of a running wpf application from background processes in task manager. Pin
Naushad Ansari15-Jun-17 23:24
Naushad Ansari15-Jun-17 23:24 
GeneralRe: Stop user from killing of a running wpf application from background processes in task manager. Pin
Pete O'Hanlon15-Jun-17 23:46
mvePete O'Hanlon15-Jun-17 23:46 
QuestionBind To DP On Control Pin
Kevin Marois15-Jun-17 5:26
professionalKevin Marois15-Jun-17 5:26 
AnswerRe: Bind To DP On Control Pin
Pete O'Hanlon15-Jun-17 6:35
mvePete O'Hanlon15-Jun-17 6:35 
GeneralRe: Bind To DP On Control Pin
Kevin Marois15-Jun-17 6:39
professionalKevin Marois15-Jun-17 6:39 
GeneralRe: Bind To DP On Control Pin
Richard Deeming15-Jun-17 6:58
mveRichard Deeming15-Jun-17 6:58 
GeneralRe: Bind To DP On Control Pin
Kevin Marois15-Jun-17 7:03
professionalKevin Marois15-Jun-17 7:03 
AnswerRe: Bind To DP On Control Pin
BenScharbach12-Aug-17 9:06
BenScharbach12-Aug-17 9:06 
QuestionCommand Binding In User Control Pin
Kevin Marois9-Jun-17 12:24
professionalKevin Marois9-Jun-17 12:24 
AnswerRe: Command Binding In User Control Pin
Pete O'Hanlon9-Jun-17 21:26
mvePete O'Hanlon9-Jun-17 21:26 
GeneralRe: Command Binding In User Control Pin
Kevin Marois12-Jun-17 5:01
professionalKevin Marois12-Jun-17 5:01 
QuestionStyle User Control Pin
Kevin Marois22-May-17 5:19
professionalKevin Marois22-May-17 5:19 
AnswerRe: Style User Control Pin
eddieangel15-Sep-17 10:28
eddieangel15-Sep-17 10:28 
QuestionBind ColumnGroup text Pin
Mycroft Holmes18-May-17 16:01
professionalMycroft Holmes18-May-17 16:01 
AnswerRe: Bind ColumnGroup text (Resolved) Pin
Mycroft Holmes23-May-17 22:47
professionalMycroft Holmes23-May-17 22:47 
QuestionCustom SplitButton Control Styling Pin
Kevin Marois18-May-17 10:24
professionalKevin Marois18-May-17 10:24 
QuestionRe: Custom SplitButton Control Styling Pin
Gerry Schmitz18-May-17 11:34
mveGerry Schmitz18-May-17 11:34 
AnswerRe: Custom SplitButton Control Styling Pin
Kevin Marois18-May-17 12:37
professionalKevin Marois18-May-17 12:37 
GeneralRe: Custom SplitButton Control Styling Pin
Gerry Schmitz18-May-17 12:55
mveGerry Schmitz18-May-17 12:55 
GeneralRe: Custom SplitButton Control Styling Pin
Kevin Marois18-May-17 19:03
professionalKevin Marois18-May-17 19:03 
GeneralRe: Custom SplitButton Control Styling Pin
Gerry Schmitz18-May-17 19:37
mveGerry Schmitz18-May-17 19:37 
GeneralRe: Custom SplitButton Control Styling Pin
Kevin Marois19-May-17 5:04
professionalKevin Marois19-May-17 5:04 

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.