Exemplo n.º 1
0
        private void InsertByDockPosition(LayoutContext layoutContext, System.Windows.Controls.Dock?defaultPosition = null)
        {
            Debug.Assert(!IsIdle);

            if (LayoutContexts.Count > 1)
            {
                //  See if the visual has a DockPosition property. If so, automatically
                //  position the child.

                LayoutContext reference = (LayoutContexts[0] == layoutContext ? LayoutContexts[1] : LayoutContexts[0]);
                System.Windows.Controls.Dock?dockPosition = GetDockPosition(layoutContext.DockableCollection);
                switch (dockPosition ?? defaultPosition)
                {
                case null:
                    break;

                case System.Windows.Controls.Dock.Bottom:
                    layoutContext.DockableCollection.HorizontalContentAlignment = HorizontalAlignment.Stretch;
                    layoutContext.InsertBottom(reference);
                    break;

                case System.Windows.Controls.Dock.Left:
                    layoutContext.DockableCollection.VerticalContentAlignment = VerticalAlignment.Stretch;
                    layoutContext.InsertLeft(reference);
                    break;

                case System.Windows.Controls.Dock.Right:
                    layoutContext.DockableCollection.VerticalContentAlignment = VerticalAlignment.Stretch;
                    layoutContext.InsertRight(reference);
                    break;

                case System.Windows.Controls.Dock.Top:
                    layoutContext.DockableCollection.HorizontalContentAlignment = HorizontalAlignment.Stretch;
                    layoutContext.InsertTop(reference);
                    break;

                default:
                    throw new ArgumentException("Invalid value: " + (dockPosition.HasValue ? dockPosition.Value.ToString() : "<null>"), "DockPosition");
                }
            }
        }