예제 #1
0
        JsonObject DumpVisualTree(JsonValue payload)
        {
            var payloadObj      = payload.GetObject();
            var accessibilityId = payloadObj.GetNamedString("accessibilityId");

            var additionalProperties = new List <string>();

            if (payloadObj.ContainsKey("additionalProperties"))
            {
                foreach (JsonValue prop in payloadObj.GetNamedArray("additionalProperties"))
                {
                    additionalProperties.Add(prop.GetString());
                }
            }

            var rootDump = VisualTreeDumper.DumpTree(this, null, additionalProperties, new AttachedProperty[] {
                new AttachedProperty()
                {
                    Name = "Top", Property = Microsoft.ReactNative.ViewPanel.TopProperty
                },
                new AttachedProperty()
                {
                    Name = "Left", Property = Microsoft.ReactNative.ViewPanel.LeftProperty
                }
            });
            var element = VisualTreeDumper.FindElementByAutomationId(JsonObject.Parse(rootDump), accessibilityId);

            return(element);
        }
        JsonObject DumpVisualTree(JsonValue payload)
        {
            var payloadObj      = payload.GetObject();
            var accessibilityId = payloadObj.GetNamedString("accessibilityId");

            var additionalProperties = new List <string>();

            if (payloadObj.ContainsKey("additionalProperties"))
            {
                foreach (JsonValue prop in payloadObj.GetNamedArray("additionalProperties"))
                {
                    additionalProperties.Add(prop.GetString());
                }
            }

            var attachedProperties = new AttachedProperty[] {
                new AttachedProperty()
                {
                    Name = "Top", Property = Microsoft.ReactNative.ViewPanel.TopProperty
                },
                new AttachedProperty()
                {
                    Name = "Left", Property = Microsoft.ReactNative.ViewPanel.LeftProperty
                }
            };
            var rootDump = VisualTreeDumper.DumpTree(this, null, additionalProperties, attachedProperties);
            var element  = VisualTreeDumper.FindElementByAutomationId(JsonObject.Parse(rootDump), accessibilityId);

            if (element != null)
            {
                return(element);
            }

            if (accessibilityId.StartsWith("*"))
            {
                accessibilityId = accessibilityId.Substring(1);

                foreach (var popup in VisualTreeHelper.GetOpenPopups(Window.Current))
                {
                    // XAML's VisualTreeHelper returns 0 for GetChildrenCount of a popup root, so use the popup's child
                    var popupChildDump = VisualTreeDumper.DumpTree(popup.Child, null, additionalProperties, attachedProperties);

                    var json = JsonObject.Parse(popupChildDump);
                    if (accessibilityId == "")
                    {
                        element = json;
                    }
                    else
                    {
                        element = VisualTreeDumper.FindElementByAutomationId(json, accessibilityId);
                    }
                    if (element != null)
                    {
                        break;
                    }
                }
            }
            return(element);
        }
        public static string DumpVisualTree(DependencyObject root, IPropertyValueTranslator translator = null, IFilter filter = null, IVisualTreeLogger logger = null)
        {
            VisualTreeLog.LogDebugInfo("DumpVisualTree");

            string content = "";

            RunOnUIThread.Execute(() =>
            {
                content = VisualTreeDumper.DumpToXML(root, translator, filter, logger);
            });
            return(content);
        }
        JsonObject DumpVisualTree(JsonValue payload)
        {
            var payloadObj      = payload.GetObject();
            var accessibilityId = payloadObj.GetNamedString("accessibilityId");

            var additionalProperties = new List <string>();

            if (payloadObj.ContainsKey("additionalProperties"))
            {
                foreach (JsonValue prop in payloadObj.GetNamedArray("additionalProperties"))
                {
                    additionalProperties.Add(prop.GetString());
                }
            }

            var rootDump = VisualTreeDumper.DumpTree(this, null, additionalProperties, DumpTreeMode.Json);
            var element  = VisualTreeDumper.FindElementByAutomationId(JsonObject.Parse(rootDump), accessibilityId);

            return(element);
        }
 protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
 {
     LogicalTreeDumper.Dump(this);
     VisualTreeDumper.Dump(this);
 }
예제 #6
0
 private void MainPage_Loaded(object sender, RoutedEventArgs e)
 {
     var xaml = VisualTreeDumper.DumpTree(this, null, Array.Empty <string>(), new AttachedProperty[0]);
 }