Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This may be a little long, here would be my best guess:</p> <pre><code>public class CustomClass : INotifyPropertyChanged { public CustomClass() { sub1item = new ObservableDictionary&lt;string, InnerClass&gt;(); // This next line may not be necessary... Changes might propogate up. sub1item.CollectionChanged += () =&gt; NotifyPropertyChange("Sub1Item"); } private ObservableDictionary&lt;string, InnerClass&gt; sub1item; public ObservableDictionary&lt;string, InnerClass&gt; Sub1Item { get { return sub1item; } private set { sub1item = value; NotifyPropertyChange("Sub1Item"); } } public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged(String info) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(info)); } } } public class InnerClass : INotifyPropertyChanged { public SomeEnum Status { get { return this.status; } private set { this.status = value; NotifyPropertyChange("Status"); } } public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged(String info) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(info)); } } } </code></pre> <p>Just make sure you update your status by calling Status = something, and not directly through this.status</p> <p><strong>Edit:</strong> If you're just looking to ONLY update the single object that got the updated status, I'm not sure that this will do it. I suspect this will signal that Sub1Item changed, but mainitems will likely not know about the individual object. It depends on your implementation.</p> <p>If you created a DataTemplate for CustomClass, which had a binding to Sub1Item, then your binding will properly update for only the updated status</p> <pre><code>&lt;DataTemplate DataType="{x:Type myClrNamespace:InnerClass}"&gt; &lt;Grid&gt; &lt;TextBlock Text={Binding Path=Status}/&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; ... &lt;ListBox x:Name="listStatus"/&gt; </code></pre> <p>Then in the C# somewhere, you could have: <code>listStatus = mainlist[0].Sub1Item;</code> After seeing your example of your TreeView ItemTemplate though, I'm not sure anymore.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload