Exemple #1
0
        static void IdChangedEventManagerChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            DependencyObject Element = (DependencyObject)sender;

            // Clear local path, so that parent value is inherited for this element
            PersistentProperty.ReEvaluateIdPath(Element);
        }
Exemple #2
0
 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;
 }
Exemple #3
0
        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);
        }
Exemple #4
0
        private static void NotifyChildrenThatIdPathChanged(DependencyObject element)
        {
            if (element is Visual || element is Visual3D)
            {
                for (int Index = 0; Index < VisualTreeHelper.GetChildrenCount(element); Index++)
                {
                    DependencyObject Child = VisualTreeHelper.GetChild(element, Index);

                    if (Child.ReadLocalValue(PersistentProperty.IdPathProperty) != DependencyProperty.UnsetValue)
                    {
                        //there is a Context registered. this means, the context path must be re-evaluated.
                        //re-evaluation of children will be done in the called method
                        PersistentProperty.ReEvaluateIdPath(Child);
                    }
                    else
                    {
                        //no context is specified here, so check the children
                        PersistentProperty.NotifyChildrenThatIdPathChanged(Child);
                    }
                }
            }
        }
Exemple #5
0
            // 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));
            }