Пример #1
0
        /// <summary>
        /// Validates and corrects the DockWidth/DockHeight properties of the children.
        /// </summary>
        private void ValidateDockSizes()
        {
            // Make all sizes positive.
            // Absolute sizes must not be less than the MinWidth/MinHeight values.
            foreach (var child in Children)
            {
                var element = child as FrameworkElement;
                if (element == null)
                {
                    continue;
                }

                var width = DockControl.GetDockWidth(element);
                if (width.IsAbsolute && width.Value < element.MinWidth)
                {
                    DockControl.SetDockWidth(element, new GridLength(element.MinWidth, width.GridUnitType));
                }
                else if (width.Value < 0)
                {
                    DockControl.SetDockWidth(element, new GridLength(0, width.GridUnitType));
                }

                var height = DockControl.GetDockHeight(element);
                if (height.IsAbsolute && height.Value < element.MinHeight)
                {
                    DockControl.SetDockHeight(element, new GridLength(element.MinHeight, height.GridUnitType));
                }
                else if (height.Value < 0)
                {
                    DockControl.SetDockHeight(element, new GridLength(0, height.GridUnitType));
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Gets the primary DockWidth/DockHeight value for the given element.
        /// </summary>
        private static GridLength GetPrimaryDockSize(DependencyObject element, Orientation orientation)
        {
            if (element == null)
            {
                return(GridLength.Auto);
            }

            return((orientation == Orientation.Vertical) ? DockControl.GetDockHeight(element) : DockControl.GetDockWidth(element));
        }