Click here to Skip to main content
15,885,985 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Style Not being Applied Pin
Kevin Marois24-Jul-17 10:17
professionalKevin Marois24-Jul-17 10:17 
GeneralRe: Style Not being Applied Pin
Richard Deeming25-Jul-17 0:37
mveRichard Deeming25-Jul-17 0:37 
GeneralRe: Style Not being Applied Pin
Kevin Marois25-Jul-17 4:36
professionalKevin Marois25-Jul-17 4:36 
QuestionHandle DataGrid Row Model Property Change Pin
Kevin Marois21-Jun-17 12:45
professionalKevin Marois21-Jun-17 12:45 
AnswerRe: Handle DataGrid Row Model Property Change Pin
Mycroft Holmes21-Jun-17 20:54
professionalMycroft Holmes21-Jun-17 20:54 
AnswerRe: Handle DataGrid Row Model Property Change Pin
Pete O'Hanlon21-Jun-17 21:46
mvePete O'Hanlon21-Jun-17 21:46 
GeneralRe: Handle DataGrid Row Model Property Change Pin
Kevin Marois22-Jun-17 4:01
professionalKevin Marois22-Jun-17 4:01 
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 

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.