コード例 #1
0
        //protected override bool IsItemItsOwnContainerOverride(object item)
        //{
        //    return item is BreadcrumbItem;
        //}

        //protected override DependencyObject GetContainerForItemOverride()
        //{
        //    BreadcrumbItem item = new BreadcrumbItem();
        //    return item;
        //}

        /// <summary>
        /// Perform a special measurement that checks whether to collapse the header.
        /// </summary>
        /// <param name="constraint"></param>
        /// <returns></returns>
        protected override Size MeasureOverride(Size constraint)
        {
            if (SelectedItem != null)
            {
                headerControl.IsVisible = true;
                headerControl.Measure(constraint);
                Size size = new Size(constraint.Width - headerControl.DesiredSize.Width, constraint.Height);
                selectedControl.Measure(new Size(double.PositiveInfinity, constraint.Height));
                double width = headerControl.DesiredSize.Width + selectedControl.DesiredSize.Width;
                if (width > constraint.Width || (IsRoot && SelectedItem != null))
                {
                    headerControl.IsVisible = false;
                }
            }
            else if (headerControl != null)
            {
                headerControl.IsVisible = true;
            }
            IsOverflow = headerControl != null ? headerControl.IsVisible != true : false;

            Size result = base.MeasureOverride(constraint);

            return(result);
        }
コード例 #2
0
 public static Size GetMinControlSize(Layoutable control)
 {
     control.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
     control.Arrange(new Rect(control.DesiredSize));
     return(control.Bounds.Size);
 }