示例#1
0
        /// <summary>
        /// The desired size of a Track is the width (if vertically oriented) or height (if horizontally
        /// oriented) of the Thumb.
        ///
        /// When ViewportSize is NaN:
        ///    The thumb is measured to find the other dimension.
        /// Otherwise:
        ///    Zero size is returned; Track can scale to any size along its children.
        ///    This means that it will occupy no space (and not display) unless made larger by a parent or specified size.
        /// <seealso cref="FrameworkElement.MeasureOverride" />
        /// </summary>
        protected override Size MeasureOverride(Size availableSize)
        {
            Size desiredSize = new Size(0.0, 0.0);

            // Only measure thumb
            // Repeat buttons will be sized based on thumb
            if (Thumb != null)
            {
                Thumb.Measure(availableSize);
                desiredSize = Thumb.DesiredSize;
            }

            if (!double.IsNaN(ViewportSize))
            {
                // ScrollBar can shrink to 0 in the direction of scrolling
                if (Orientation == Orientation.Vertical)
                {
                    desiredSize.Height = 0.0;
                }
                else
                {
                    desiredSize.Width = 0.0;
                }
            }

            return(desiredSize);
        }
示例#2
0
        protected override Size MeasureOverride(Size availableSize)
        {
            if (Thumb != null)
            {
                Thumb.Measure(availableSize);
                return(GetMainSize(0).Combine(Thumb.DesiredSize));
            }

            return(Size.Zero);
        }