Click here to Skip to main content
14,768,167 members
Home » Discussions » Silverlight / WPF
   

Silverlight / WPF

 
GeneralRe: Style Not being Applied Pin
Kevin Marois24-Jul-17 11:17
professionalKevin Marois24-Jul-17 11:17 
GeneralRe: Style Not being Applied Pin
Richard Deeming25-Jul-17 1:37
mveRichard Deeming25-Jul-17 1:37 
GeneralRe: Style Not being Applied Pin
Kevin Marois25-Jul-17 5:36
professionalKevin Marois25-Jul-17 5:36 
QuestionHandle DataGrid Row Model Property Change Pin
Kevin Marois21-Jun-17 13:45
professionalKevin Marois21-Jun-17 13:45 
AnswerRe: Handle DataGrid Row Model Property Change Pin
Mycroft Holmes21-Jun-17 21:54
professionalMycroft Holmes21-Jun-17 21:54 
AnswerRe: Handle DataGrid Row Model Property Change Pin
Pete O'Hanlon21-Jun-17 22:46
mvePete O'Hanlon21-Jun-17 22:46 
GeneralRe: Handle DataGrid Row Model Property Change Pin
Kevin Marois22-Jun-17 5:01
professionalKevin Marois22-Jun-17 5:01 
GeneralRe: Handle DataGrid Row Model Property Change Pin
Pete O'Hanlon22-Jun-17 6:03
mvePete O'Hanlon22-Jun-17 6: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:
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:
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 15:41
professionalMycroft Holmes22-Jun-17 15:41 
GeneralRe: Handle DataGrid Row Model Property Change Pin
Pete O'Hanlon22-Jun-17 22:18
mvePete O'Hanlon22-Jun-17 22:18 
GeneralStop user from killing of a running wpf application from background processes in task manager. Pin
Naushad Ansari16-Jun-17 0:24
MemberNaushad Ansari16-Jun-17 0:24 
GeneralRe: Stop user from killing of a running wpf application from background processes in task manager. Pin
Pete O'Hanlon16-Jun-17 0:46
mvePete O'Hanlon16-Jun-17 0:46 
QuestionBind To DP On Control Pin
Kevin Marois15-Jun-17 6:26
professionalKevin Marois15-Jun-17 6:26 
AnswerRe: Bind To DP On Control Pin
Pete O'Hanlon15-Jun-17 7:35
mvePete O'Hanlon15-Jun-17 7:35 
GeneralRe: Bind To DP On Control Pin
Kevin Marois15-Jun-17 7:39
professionalKevin Marois15-Jun-17 7:39 
GeneralRe: Bind To DP On Control Pin
Richard Deeming15-Jun-17 7:58
mveRichard Deeming15-Jun-17 7:58 
GeneralRe: Bind To DP On Control Pin
Kevin Marois15-Jun-17 8:03
professionalKevin Marois15-Jun-17 8:03 
AnswerRe: Bind To DP On Control Pin
BenScharbach12-Aug-17 10:06
MemberBenScharbach12-Aug-17 10:06 
QuestionCommand Binding In User Control Pin
Kevin Marois9-Jun-17 13:24
professionalKevin Marois9-Jun-17 13:24 
AnswerRe: Command Binding In User Control Pin
Pete O'Hanlon9-Jun-17 22:26
mvePete O'Hanlon9-Jun-17 22:26 
GeneralRe: Command Binding In User Control Pin
Kevin Marois12-Jun-17 6:01
professionalKevin Marois12-Jun-17 6:01 
QuestionStyle User Control Pin
Kevin Marois22-May-17 6:19
professionalKevin Marois22-May-17 6:19 
AnswerRe: Style User Control Pin
eddieangel15-Sep-17 11:28
Membereddieangel15-Sep-17 11:28 
QuestionBind ColumnGroup text Pin
Mycroft Holmes18-May-17 17:01
professionalMycroft Holmes18-May-17 17:01 
AnswerRe: Bind ColumnGroup text (Resolved) Pin
Mycroft Holmes23-May-17 23:47
professionalMycroft Holmes23-May-17 23: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.