public static object GetChild(object source, int index) { if (DXMethods.IsChrome(source)) { return(DXMethods.GetRoot(source)); } if (DXMethods.IsIFrameworkRenderElementContext(source)) { var control = DXMethods.Is(source, "RenderControlBaseContext", "DevExpress.Xpf.Core.Native", false) ? ((dynamic)source).Control : null; var rcc = DXMethods.RenderChildrenCount(source); if (index >= rcc) { if (index == rcc && control != null) { return(control); } return(null); } return(DXMethods.GetRenderChild(source, index)); } if (source is Visual) { return(VisualTreeHelper.GetChild((Visual)source, index)); } return(null); }
public VisualTreeItem FindNode(object target) { // it might be faster to have a map for the lookup // check into this at some point if (this.Target == target) { if (DXMethods.IsChrome(Target) && target is IInputElement) { var root = DXMethods.GetRoot(Target); if (root != null) { var child = RenderTreeHelper.HitTest(root, System.Windows.Input.Mouse.GetPosition((IInputElement)target)); var node = FindNode(child); if (node != null) { return(node); } } } return(this); } foreach (VisualTreeItem child in this.Children) { VisualTreeItem node = child.FindNode(target); if (node != null) { return(node); } } return(null); }
public static int GetChildrenCount(object source) { if (DXMethods.IsChrome(source)) { object root = DXMethods.GetRoot(source); if (root != null) { return(1); } } if (DXMethods.IsIFrameworkRenderElementContext(source)) { int hasControl = DXMethods.Is(source, "RenderControlBaseContext", "DevExpress.Xpf.Core.Native", false) && ((dynamic)source).Control != null ? 1 : 0; return(DXMethods.RenderChildrenCount(source) + hasControl); } if (source is Visual) { return(VisualTreeHelper.GetChildrenCount((Visual)source)); } return(0); }