public SubPropertyEditorAutomationPeer(SubPropertyEditor editor) : base(editor) { _editor = editor; // Hook into the VisualsChanged event so that this peer can invalidate // itself appropriately if (editor != null) { editor.VisualsChanged += new EventHandler(OnEditorVisualsChanged); } _children = new List <AutomationPeer>(); }
// ISelectionPathInterpreter Members public DependencyObject ResolveSelectionPath(CategoryList root, SelectionPath path, out bool pendingGeneration) { pendingGeneration = false; if (path == null || !string.Equals(PathTypeId, path.PathTypeId)) { Debug.Fail("Invalid SelectionPath specified."); return(null); } if (root == null) { Debug.Fail("No CategoryList specified."); return(null); } string[] pathValues = path.Path.Split(','); if (pathValues.Length < 1) { Debug.Fail("Invalid SelectionPath specified."); return(null); } // // Note: By the time this method gets called, all the visuals should have been expanded // and rendered. Hence, if we can't find a visual in the visual tree, it doesn't exist // and we shouldn't worry about trying to expand some parent visual and waiting for it // to render. // ModelCategoryEntry parentCategory; PropertyEntry currentProperty = root.FindPropertyEntry(PersistedStateUtilities.Unescape(pathValues[0]), out parentCategory); PropertyContainer currentContainer = root.FindPropertyEntryVisual(currentProperty, parentCategory, out pendingGeneration); DependencyObject lastFoundContainer = currentContainer; int pathIndex = 1; while (currentContainer != null && pathIndex < pathValues.Length) { SubPropertyEditor subPropertyEditor = VisualTreeUtils.GetTemplateChild <SubPropertyEditor>(currentContainer); if (subPropertyEditor == null) { break; } // If the subpropertyEditor is not expanded and is expandable, we won't be able to get the target property's visual // element, Expand it, set pendingGeneration to True, and return null. Expect the caller to call again. if (subPropertyEditor.IsExpandable && !subPropertyEditor.IsExpanded) { subPropertyEditor.IsExpanded = true; pendingGeneration = true; return(null); } PropertyEntry property = subPropertyEditor.FindSubPropertyEntry(PersistedStateUtilities.Unescape(pathValues[pathIndex])); if (property == null) { break; } currentContainer = subPropertyEditor.FindSubPropertyEntryVisual(property); lastFoundContainer = currentContainer ?? lastFoundContainer; pathIndex++; } if (lastFoundContainer == null) { return(null); } return(lastFoundContainer); }