Пример #1
0
        public void AddElement(FrameworkElement parent, FrameworkElement element, bool pushTask = false)
        {
            IRenderer parentRenderer = parent.GetRenderer();
            IRenderer childRenderer  = element.GetRenderer();

            element.AddAdorner((Adorner)childRenderer);

            if (parent.DataContext != null && parent.DataContext is DependencyObject dataContext)
            {
                // Add On PObject Parent
                ObjectContentHelper.GetContent(
                    dataContext,
                    pi => pi.SetValue(dataContext, element.DataContext), // Single Content
                    list => list.SafeAdd(element.DataContext));          // List Content
            }

            // Add On WPF Parent
            ObjectContentHelper.GetContent(
                parent,
                pi => pi.SetValue(parent, element),  // Single Content
                list => list.SafeAdd(element));      // List Content

            this.AddElementCore(childRenderer);

            // Notice child added
            parentRenderer?.AddChild(childRenderer, childRenderer.Metadata.CreatedPosition);
        }