public SettingValue(PropertyStoreAdapter propertyStore, string name, object defaultValue, DependencyObject target) { this.propertyStore = propertyStore; this.name = name; this.defaultValue = defaultValue; this.context = PersistentProperty.GetIdPath(target); PersistentProperty.AddIDPathChangedEventHandler(target, this.ContextChanged); this.value = this.GetProperty(); this.value.PropertyChanged += this.ValueChanged; }
private static void ReEvaluateIdPath(DependencyObject element) { PersistentProperty.ClearIdPath(element); //Get (inherited) parent path string ParentIdPath = PersistentProperty.GetIdPath(element); string Id = PersistentProperty.GetId(element); if (Id != null) { //Compute and set new path PersistentProperty.SetIdPath(element, ParentIdPath != null ? $"{ParentIdPath}.{Id}" : Id); } PersistentProperty.NotifyChildrenThatIdPathChanged(element); }
// ReSharper restore UnusedMember.Local // ReSharper restore MemberCanBePrivate.Local // ReSharper restore UnusedMemberInPrivateClass private void ContextChanged(object sender, DependencyPropertyChangedEventArgs e) { this.context = PersistentProperty.GetIdPath((DependencyObject)sender); this.SetValue(this.GetProperty()); this.InvokePropertyChanged(nameof(SettingValue.Value)); }