Пример #1
0
        void UpdateSizes()
        {
            var info = scroller.GetScrollInfo();

            if (info != null)
            {
                var content      = (swc.Border)scroller.Content;
                var viewportSize = new sw.Size(info.ViewportWidth, info.ViewportHeight);
                var prefSize     = Content.GetPreferredSize(new sw.Size(double.MaxValue, double.MaxValue));

                // hack for when a scrollable is in a group box it expands vertically indefinitely
                // -2 since when you resize the scrollable it grows slowly
                if (Widget.FindParent <GroupBox>() != null)
                {
                    viewportSize.Height = Math.Max(0, viewportSize.Height - 2);
                }

                if (ExpandContentWidth)
                {
                    content.Width = Math.Max(0, Math.Max(prefSize.Width, viewportSize.Width));
                }
                else
                {
                    content.Width = prefSize.Width;
                }

                if (ExpandContentHeight)
                {
                    content.Height = Math.Max(0, Math.Max(prefSize.Height, viewportSize.Height));
                }
                else
                {
                    content.Height = prefSize.Height;
                }

                scroller.InvalidateMeasure();
            }
        }
Пример #2
0
        void UpdateSizes()
        {
            var info = scroller.GetScrollInfo();

            if (info != null)
            {
                var content      = (swc.Border)scroller.Content;
                var viewportSize = new sw.Size(info.ViewportWidth, info.ViewportHeight);
                var prefSize     = Content.GetPreferredSize(WpfConversions.PositiveInfinitySize);

                // hack for when a scrollable is in a group box it expands vertically
                if (Widget.FindParent <GroupBox>() != null)
                {
                    viewportSize.Height = Math.Max(0, viewportSize.Height - 1);
                }

                if (ExpandContentWidth)
                {
                    content.Width = Math.Max(0, Math.Max(prefSize.Width, viewportSize.Width));
                }
                else
                {
                    content.Width = prefSize.Width;
                }

                if (ExpandContentHeight)
                {
                    content.Height = Math.Max(0, Math.Max(prefSize.Height, viewportSize.Height));
                }
                else
                {
                    content.Height = prefSize.Height;
                }

                scroller.InvalidateMeasure();
            }
        }