c# - TreeViewItem not updating with bound ItemsSource, ObservableCollection, and INotifyPropertyChanged -


i know question has been asked lot after trying of different answers still can't work me. object i'm trying bind updating correctly in code behind thing isn't working children of treeviewitem updating when itemssource changed.

it seems have set correctly maybe there how tying things making not work. using c# .net 4.5 wpf project in vs 2015 in windows 7. binding static classes' static property has method treeviewitem's itemssource , setting displaymemberpath.

xaml:

<!-- menu tree -->         <treeview grid.column="0"                   x:name="menutree"                   background="transparent"                   borderthickness="0">             <!-- profiles tvi -->             <treeviewitem header="{x:static loc:resources.profiles}"                           isexpanded="true">                 <!-- color profile tvi -->                 <treeviewitem x:name="colortvi"                               header="{x:static loc:resources.colorprofiles}"                               mouserightbuttondown="colortvi_mouserightbuttondown"                               displaymemberpath="name"                               itemssource="{binding source={x:static local:shared.colorprofiles}, mode=oneway}" />                  <treeviewitem ... 

class / properties being bound to:

public static class shared {     #region getter / setter      // notify property changed     public static notifychanged notify { get; set; } = new notifychanged();      // profiles have been created     public static list<profile> profiles     {         { return _profiles; }         set         {             // set profile             _profiles = value;             notify.onpropertychanged(nameof(profiles));             notify.onpropertychanged(nameof(colorprofiles));         }     }     private static list<profile> _profiles = new list<profile>();      // color profiles     public static observablecollection<colorprofile> colorprofiles     {                 {             return new observablecollection<colorprofile>(                 profiles?.where(m => m.gettype() == typeof(colorprofile))?.cast<colorprofile>()?.tolist() ??                 new list<colorprofile>());         }     }      #endregion } 

the notifychanged class:

// property changed class public class notifychanged : inotifypropertychanged {      // property changed event     public event propertychangedeventhandler propertychanged;      // notify property changed     public void onpropertychanged(string name)     {         propertychanged?.invoke(this, new propertychangedeventargs(name));     }  } 

i work without having call refresh() in code behind. have tried binding shared.profiles directly doesn't any. colorprofile base class inherits profile.

hopefully there's stupid, simple thing i'm missing. in advance help.

update :

on further inspection looks itemssource isn't updating. during debugging can see in control's property explorer itemssource bound observablecollection itemssource not reflecting changes made list. if manually bind in code behind works.

notify 1 shouting propertychanged, on itself.

no 1 binded notify no 1 updating.

the 1 needs implement inotifypropertychanged, or inherit notifychanged shared.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -