// Token: 0x06004A85 RID: 19077 RVA: 0x001500D8 File Offset: 0x0014E2D8
        private static void OnDockChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            UIElement uielement = d as UIElement;

            if (uielement != null)
            {
                DockPanel dockPanel = VisualTreeHelper.GetParent(uielement) as DockPanel;
                if (dockPanel != null)
                {
                    dockPanel.InvalidateMeasure();
                }
            }
        }
Ejemplo n.º 2
0
        private static void OnDockChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            UIElement uie = d as UIElement; //it may be anyting, like FlowDocument...

            if (uie != null)
            {
                DockPanel p = VisualTreeHelper.GetParent(uie) as DockPanel;
                if (p != null)
                {
                    p.InvalidateMeasure();
                }
            }
        }
Ejemplo n.º 3
0
        public void DockPanelLayoutTest()
        {
            DockPanel panel = new DockPanel();
            panel.InvalidateMeasure();

            FrameworkElement child1 = new FrameworkElement { Width = 100 };
            FrameworkElement child2 = new FrameworkElement { Height = 100 };
            FrameworkElement child3 = new FrameworkElement { Width = 100 };
            FrameworkElement child4 = new FrameworkElement { Height = 100 };
            FrameworkElement child5 = new FrameworkElement();

            panel.Children.Add(child1);
            panel.Children.Add(child2);
            panel.Children.Add(child3);
            panel.Children.Add(child4);
            panel.Children.Add(child5);

            DockPanel.SetDock(child1, Dock.Left);
            DockPanel.SetDock(child2, Dock.Top);
            DockPanel.SetDock(child3, Dock.Right);
            DockPanel.SetDock(child4, Dock.Bottom);

            panel.Measure(new Size(1000, 1000));

            Assert.AreEqual(new Size(200, 200), panel.DesiredSize);

            panel.Arrange(new Rect(1000, 1000));

            Assert.AreEqual(new Size(1000, 1000), panel.VisualSize);

            Assert.AreEqual(new Size(100, 1000), child1.VisualSize);
            Assert.AreEqual(new Size(900, 100), child2.VisualSize);
            Assert.AreEqual(new Size(100, 900), child3.VisualSize);
            Assert.AreEqual(new Size(800, 100), child4.VisualSize);
            Assert.AreEqual(new Size(800, 800), child5.VisualSize);

            Assert.AreEqual(new Point(0, 0), child1.VisualOffset);
            Assert.AreEqual(new Point(100, 0), child2.VisualOffset);
            Assert.AreEqual(new Point(900, 100), child3.VisualOffset);
            Assert.AreEqual(new Point(100, 900), child4.VisualOffset);
            Assert.AreEqual(new Point(100, 100), child5.VisualOffset);
        }
Ejemplo n.º 4
0
        private static void OnDockPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            // Ignore the change if requested
            if (_ignorePropertyChange)
            {
                _ignorePropertyChange = false;
                return;
            }

            UIElement element = (UIElement)d;
            Dock      value   = (Dock)e.NewValue;

            // Validate the Dock property
            if ((value != Dock.Left) &&
                (value != Dock.Top) &&
                (value != Dock.Right) &&
                (value != Dock.Bottom))
            {
                // Reset the property to its original state before throwing
                _ignorePropertyChange = true;
                element.SetValue(DockProperty, (Dock)e.OldValue);

                string message = string.Format(
                    CultureInfo.InvariantCulture,
                    "InvalidValue",
                    value);
                throw new ArgumentException(message, "value");
            }

            // Cause the DockPanel to update its layout when a child changes
            DockPanel panel = VisualTreeHelper.GetParent(element) as DockPanel;

            if (panel != null)
            {
                panel.InvalidateMeasure();
            }
        }