private static void ReEvaluateContextPath(DependencyObject element) { UiFeatureManagement.ClearContextPath(element); //Get (inherited) parent path string ParentContextPath = UiFeatureManagement.GetContextPath(element); string Context = UiFeatureManagement.GetContext(element); if (Context != null) { //Compute and set new path UiFeatureManagement.SetContextPath(element, ParentContextPath != null ? $"{ParentContextPath}/{Context}" : Context); } UiFeatureManagement.NotifyChildrenThatContextPathChanged(element); }
private static void NotifyChildrenThatContextPathChanged(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(UiFeatureManagement.ContextPathProperty) != DependencyProperty.UnsetValue) //if ( UIFeatureManagement.GetContext(Child) != null) { //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 UiFeatureManagement.ReEvaluateContextPath(Child); } else { //no context is specified here, so check the children UiFeatureManagement.NotifyChildrenThatContextPathChanged(Child); } } } }