瀏覽代碼

Removed ContentSize setter, replaced with SetContentSize

Tig 1 年之前
父節點
當前提交
36b9171276

+ 67 - 19
Terminal.Gui/View/ViewContent.cs

@@ -123,16 +123,64 @@ public partial class View
     internal Size? _contentSize;
 
     /// <summary>
-    ///     Gets or sets the size of the View's content. If <see langword="null"/>, the value will be the same as the size of <see cref="Viewport"/>,
-    ///     and <c>Viewport.Location</c> will always be <c>0, 0</c>.
+    ///     Sets the size of the View's content.
     /// </summary>
     /// <remarks>
     ///     <para>
-    ///         If a size is provided, <see cref="Viewport"/> describes the portion of the content currently visible
+    ///         By default, the content size is set to <see langword="null"/>.
+    ///     </para>
+    /// </remarks>
+    /// <param name="contentSize">
+    ///     <para>
+    ///         If <see langword="null"/>, and the View has no visible subviews, <see cref="ContentSize"/> will track the size of <see cref="Viewport"/>.
+    ///     </para>
+    ///     <para>
+    ///         If <see langword="null"/>, and the View has visible subviews, <see cref="ContentSize"/> will track the maximum position plus size of any
+    ///         visible Subviews
+    ///         and <c>Viewport.Location</c>  will track the minimum position and size of any visible Subviews.
+    ///     </para>
+    ///     <para>
+    ///         If not <see langword="null"/>, <see cref="ContentSize"/> is set to the passed value and <see cref="Viewport"/> describes the portion of the content currently visible
+    ///         to the user. This enables virtual scrolling.
+    ///     </para>
+    ///     <para>
+    ///         If not <see langword="null"/>, <see cref="ContentSize"/> is set to the passed value and the behavior of <see cref="Dim.DimAutoStyle.Content"/> will be to use the ContentSize
+    ///         to determine the size of the view.
+    ///     </para>
+    ///     <para>
+    ///         Negative sizes are not supported.
+    ///     </para>
+    /// </param>
+    public void SetContentSize (Size? contentSize)
+    {
+        if (contentSize?.Width < 0 || contentSize?.Height < 0)
+        {
+            throw new ArgumentException (@"ContentSize cannot be negative.", nameof (contentSize));
+        }
+
+        if (contentSize == _contentSize)
+        {
+            return;
+        }
+
+        _contentSize = contentSize;
+        OnContentSizeChanged (new (_contentSize));
+    }
+
+    /// <summary>
+    ///     Gets or sets the size of the View's content.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         If set to <see langword="null"/>, the value will be the same as the size of <see cref="Viewport"/>,
+    ///         and <c>Viewport.Location</c> will always be <c>0, 0</c>.
+    ///     </para>
+    ///     <para>
+    ///         If explicitly set, <see cref="Viewport"/> describes the portion of the content currently visible
     ///         to the view. This enables virtual scrolling.
     ///     </para>
     ///     <para>
-    ///         If a size is provided, the behavior of <see cref="Dim.DimAutoStyle.Content"/> will be to use the ContentSize
+    ///         If explicitly set, the behavior of <see cref="Dim.DimAutoStyle.Content"/> will be to use the ContentSize
     ///         to determine the size of the view.
     ///     </para>
     ///     <para>
@@ -142,21 +190,21 @@ public partial class View
     public Size? ContentSize
     {
         get => _contentSize ?? Viewport.Size;
-        set
-        {
-            if (value?.Width < 0 || value?.Height < 0)
-            {
-                throw new ArgumentException (@"ContentSize cannot be negative.", nameof (value));
-            }
-
-            if (value == _contentSize)
-            {
-                return;
-            }
-
-            _contentSize = value;
-            OnContentSizeChanged (new (_contentSize));
-        }
+        //set
+        //{
+        //    if (value?.Width < 0 || value?.Height < 0)
+        //    {
+        //        throw new ArgumentException (@"ContentSize cannot be negative.", nameof (value));
+        //    }
+
+        //    if (value == _contentSize)
+        //    {
+        //        return;
+        //    }
+
+        //    _contentSize = value;
+        //    OnContentSizeChanged (new (_contentSize));
+        //}
     }
 
     /// <summary>

+ 3 - 3
Terminal.Gui/Views/ListView.cs

@@ -264,7 +264,7 @@ public class ListView : View
             }
             _source = value;
 
-            ContentSize = new Size (_source?.Length ?? Viewport.Width, _source?.Count ?? Viewport.Width);
+            SetContentSize (new Size (_source?.Length ?? Viewport.Width, _source?.Count ?? Viewport.Width));
             if (IsInitialized)
             {
                 Viewport = Viewport with { Y = 0 };
@@ -336,7 +336,7 @@ public class ListView : View
             }
             else if (Viewport.Height > 0 && _selected >= Viewport.Y + Viewport.Height)
             {
-                Viewport = Viewport with { Y = _selected - Viewport.Height + 1};
+                Viewport = Viewport with { Y = _selected - Viewport.Height + 1 };
             }
 
             LayoutStarted -= ListView_LayoutStarted;
@@ -408,7 +408,7 @@ public class ListView : View
 
         if (me.Flags == MouseFlags.WheeledLeft)
         {
-            ScrollHorizontal(-1);
+            ScrollHorizontal (-1);
 
             return true;
         }

+ 17 - 7
Terminal.Gui/Views/ProgressBar.cs

@@ -61,7 +61,7 @@ public class ProgressBar : View
         set
         {
             _bidirectionalMarquee = value;
-            ContentSize = Viewport.Size with { Height = 1 };
+            SetContentSize (Viewport.Size with { Height = 1 });
         }
     }
 
@@ -74,12 +74,22 @@ public class ProgressBar : View
         {
             _fraction = Math.Min (value, 1);
             _isActivity = false;
-            ContentSize = Viewport.Size with { Height = 1 };
+            SetContentSize (Viewport.Size with { Height = 1 });
         }
     }
 
+    private ProgressBarFormat _progressBarFormat;
+
     /// <summary>Specifies the format that a <see cref="ProgressBar"/> uses to indicate the visual presentation.</summary>
-    public ProgressBarFormat ProgressBarFormat { get; set; }
+    public ProgressBarFormat ProgressBarFormat
+    {
+        get => _progressBarFormat;
+        set
+        {
+            _progressBarFormat = value;
+            SetContentSize (Viewport.Size with { Height = 1 });
+        }
+    }
 
     /// <summary>Gets/Sets the progress bar style based on the <see cref="Terminal.Gui.ProgressBarStyle"/></summary>
     public ProgressBarStyle ProgressBarStyle
@@ -109,7 +119,7 @@ public class ProgressBar : View
                     break;
             }
 
-            ContentSize = Viewport.Size with { Height = 1 };
+            SetContentSize (Viewport.Size with { Height = 1 });
         }
     }
 
@@ -120,7 +130,7 @@ public class ProgressBar : View
         set
         {
             _segmentCharacter = value;
-            ContentSize = Viewport.Size with { Height = 1 };
+            SetContentSize (Viewport.Size with { Height = 1 });
         }
     }
 
@@ -181,7 +191,7 @@ public class ProgressBar : View
 
         if (ProgressBarFormat != ProgressBarFormat.Simple && !_isActivity)
         {
-            var tf = new TextFormatter { Alignment = TextAlignment.Centered, Text = Text, AutoSize = true};
+            var tf = new TextFormatter { Alignment = TextAlignment.Centered, Text = Text, AutoSize = true };
             var attr = new Attribute (ColorScheme.HotNormal.Foreground, ColorScheme.HotNormal.Background);
 
             if (_fraction > .5)
@@ -269,7 +279,7 @@ public class ProgressBar : View
 
     private void ProgressBar_Initialized (object sender, EventArgs e)
     {
-        ContentSize = new (0, 1);
+        SetContentSize (Viewport.Size with { Height = 1 });
 
         ColorScheme = new ColorScheme (ColorScheme ?? SuperView?.ColorScheme ?? Colors.ColorSchemes ["Base"])
         {

+ 2 - 2
Terminal.Gui/Views/Slider.cs

@@ -624,11 +624,11 @@ public class Slider<T> : View
 
         if (_config._sliderOrientation == Orientation.Horizontal)
         {
-            ContentSize = new (int.Min (svWidth, CalcBestLength ()), int.Min (svHeight, CalcThickness ()));
+            SetContentSize (new (int.Min (svWidth, CalcBestLength ()), int.Min (svHeight, CalcThickness ())));
         }
         else
         {
-            ContentSize = new (int.Min (svWidth, CalcThickness ()), int.Min (svHeight, CalcBestLength ()));
+            SetContentSize (new (int.Min (svWidth, CalcThickness ()), int.Min (svHeight, CalcBestLength ())));
         }
 
         return;

+ 1 - 1
UICatalog/Scenarios/ASCIICustomButton.cs

@@ -235,7 +235,7 @@ public class ASCIICustomButtonTest : Scenario
                 pages++;
             }
 
-            _scrollView.ContentSize = new (25, pages * BUTTONS_ON_PAGE * BUTTON_HEIGHT);
+            _scrollView.SetContentSize (new (25, pages * BUTTONS_ON_PAGE * BUTTON_HEIGHT));
 
             if (_smallerWindow)
             {

+ 1 - 1
UICatalog/Scenarios/CharacterMap.cs

@@ -328,7 +328,7 @@ internal class CharMap : View
         CanFocus = true;
         CursorVisibility = CursorVisibility.Default;
 
-        ContentSize = new (RowWidth, (MaxCodePoint / 16 + 2) * _rowHeight);
+        SetContentSize (new (RowWidth, (MaxCodePoint / 16 + 2) * _rowHeight));
 
         AddCommand (
                     Command.ScrollUp,

+ 1 - 1
UICatalog/Scenarios/Clipping.cs

@@ -29,7 +29,7 @@ public class Clipping : Scenario
 
         var scrollView = new ScrollView { X = 3, Y = 3, Width = 50, Height = 20 };
         scrollView.ColorScheme = Colors.ColorSchemes ["Menu"];
-        scrollView.ContentSize = new (200, 100);
+        scrollView.SetContentSize (new (200, 100));
 
         //ContentOffset = Point.Empty,
         scrollView.AutoHideScrollBars = true;

+ 3 - 3
UICatalog/Scenarios/ContentScrolling.cs

@@ -27,7 +27,7 @@ public class ContentScrolling : Scenario
             BorderStyle = LineStyle.Rounded;
             Arrangement = ViewArrangement.Fixed;
 
-            ContentSize = new (60, 40);
+            SetContentSize (new (60, 40));
             ViewportSettings |= ViewportSettings.ClearContentOnly;
             ViewportSettings |= ViewportSettings.ClipContentOnly;
 
@@ -242,7 +242,7 @@ public class ContentScrolling : Scenario
                 return;
             }
 
-            view.ContentSize = view.ContentSize.GetValueOrDefault () with { Width = e.NewValue };
+            view.SetContentSize (view.ContentSize.GetValueOrDefault () with { Width = e.NewValue });
         }
 
         var labelComma = new Label
@@ -270,7 +270,7 @@ public class ContentScrolling : Scenario
                 return;
             }
 
-            view.ContentSize = view.ContentSize.GetValueOrDefault () with { Height = e.NewValue };
+            view.SetContentSize (view.ContentSize.GetValueOrDefault () with { Height = e.NewValue });
         }
 
         var cbClearOnlyVisible = new CheckBox

+ 1 - 1
UICatalog/Scenarios/Scrolling.cs

@@ -39,12 +39,12 @@ public class Scrolling : Scenario
             Width = 60,
             Height = 20,
             ColorScheme = Colors.ColorSchemes ["TopLevel"],
-            ContentSize = new (120, 40),
 
             //ContentOffset = Point.Empty,
             ShowVerticalScrollIndicator = true,
             ShowHorizontalScrollIndicator = true
         };
+        scrollView.SetContentSize (new (120, 40));
         scrollView.Padding.Thickness = new (1);
 
         label.Text = $"{scrollView}\nContentSize: {scrollView.ContentSize}\nContentOffset: {scrollView.ContentOffset}";

+ 6 - 5
UnitTests/Application/MouseTests.cs

@@ -235,7 +235,8 @@ public class MouseTests
     public void MouseGrabView_WithNullMouseEventView ()
     {
         var tf = new TextField { Width = 10 };
-        var sv = new ScrollView { Width = Dim.Fill (), Height = Dim.Fill (), ContentSize = new (100, 100) };
+        var sv = new ScrollView { Width = Dim.Fill (), Height = Dim.Fill () };
+        sv.SetContentSize (new (100, 100));
 
         sv.Add (tf);
         var top = new Toplevel ();
@@ -252,7 +253,7 @@ public class MouseTests
                                          Assert.True (tf.HasFocus);
                                          Assert.Null (Application.MouseGrabView);
 
-                                         Application.OnMouseEvent (new() { Position = new (5, 5), Flags = MouseFlags.ReportMousePosition });
+                                         Application.OnMouseEvent (new () { Position = new (5, 5), Flags = MouseFlags.ReportMousePosition });
 
                                          Assert.Equal (sv, Application.MouseGrabView);
 
@@ -266,15 +267,15 @@ public class MouseTests
                                          // another toplevel (Dialog) was opened
                                          Assert.Null (Application.MouseGrabView);
 
-                                         Application.OnMouseEvent (new() { Position = new (5, 5), Flags = MouseFlags.ReportMousePosition });
+                                         Application.OnMouseEvent (new () { Position = new (5, 5), Flags = MouseFlags.ReportMousePosition });
 
                                          Assert.Null (Application.MouseGrabView);
 
-                                         Application.OnMouseEvent (new() { Position = new (40, 12), Flags = MouseFlags.ReportMousePosition });
+                                         Application.OnMouseEvent (new () { Position = new (40, 12), Flags = MouseFlags.ReportMousePosition });
 
                                          Assert.Null (Application.MouseGrabView);
 
-                                         Application.OnMouseEvent (new() { Position = new (0, 0), Flags = MouseFlags.Button1Pressed });
+                                         Application.OnMouseEvent (new () { Position = new (0, 0), Flags = MouseFlags.Button1Pressed });
 
                                          Assert.Null (Application.MouseGrabView);
 

+ 2 - 2
UnitTests/View/DrawTests.cs

@@ -924,9 +924,9 @@ public class DrawTests (ITestOutputHelper _output)
         {
             Width = Dim.Fill (),
             Height = Dim.Fill (),
-            ContentSize = new Size (10, 10),
             ViewportSettings = ViewportSettings.ClipContentOnly
         };
+        view.SetContentSize (new Size (10, 10));
         view.Border.Thickness = new Thickness (1);
         view.BeginInit ();
         view.EndInit ();
@@ -957,8 +957,8 @@ public class DrawTests (ITestOutputHelper _output)
         {
             Width = Dim.Fill (),
             Height = Dim.Fill (),
-            ContentSize = new Size (10, 10),
         };
+        view.SetContentSize (new Size (10, 10));
         view.Border.Thickness = new Thickness (1);
         view.BeginInit ();
         view.EndInit ();

+ 1 - 1
UnitTests/View/FindDeepestViewTests.cs

@@ -470,7 +470,7 @@ public class FindDeepestViewTests ()
         subview.Padding.Thickness = new (1);
 
         // Scroll the subview
-        subview.ContentSize = new Size (10, 10);
+        subview.SetContentSize (new (10, 10));
         subview.Viewport = subview.Viewport with { Location = new (1, 1) };
 
         // This subview will be at the bottom-right-corner of subview

+ 4 - 2
UnitTests/View/Layout/Dim.AutoTests.cs

@@ -882,7 +882,9 @@ public class DimAutoTests (ITestOutputHelper output)
     [Fact]
     public void DimAutoStyle_Content_UsesContentSize_WhenSet ()
     {
-        var view = new View () { ContentSize = new Size (10, 5) };
+        var view = new View ();
+        view.SetContentSize (new (10, 5));
+
         var dim = Dim.Auto (Dim.DimAutoStyle.Content);
 
         int calculatedWidth = dim.Calculate (0, 100, view, Dim.Dimension.Width);
@@ -1220,7 +1222,7 @@ public class DimAutoTests (ITestOutputHelper output)
     public void DimAutoStyle_Content_UsesContentSize_If_No_Subviews ()
     {
         DimAutoTestView view = new (Auto (DimAutoStyle.Content), Auto (DimAutoStyle.Content));
-        view.ContentSize = new (5, 5);
+        view.SetContentSize (new (5, 5));
         view.SetRelativeLayout (new (10, 10));
 
         Assert.Equal (new (5, 5), view.Frame.Size);

+ 1 - 1
UnitTests/View/Layout/LayoutTests.cs

@@ -122,8 +122,8 @@ public class LayoutTests (ITestOutputHelper output)
         {
             Width = 5,
             Height = 5,
-            ContentSize = new (10, 10)
         };
+        superView.SetContentSize (new (10, 10));
         var view = new View ()
         {
             X = Pos.Center ()

+ 2 - 2
UnitTests/View/Layout/ScreenToTests.cs

@@ -108,7 +108,7 @@ public class ScreenToTests
             BorderStyle = LineStyle.Single,
         };
         var view = new View { X = viewX, Y = viewY, Width = 5, Height = 5 };
-        view.ContentSize = new (6, 6);
+        view.SetContentSize (new (6, 6));
         super.Add (view);
 
         view.Viewport = new (1, 1, 5, 5);
@@ -164,7 +164,7 @@ public class ScreenToTests
             X = viewX, Y = viewY, Width = 5, Height = 5,
             BorderStyle = LineStyle.Single,
         };
-        view.ContentSize = new (10, 10);
+        view.SetContentSize (new (10, 10));
         super.Add (view);
 
         view.Viewport = view.Viewport with { Location = new (1, 1) };

+ 6 - 6
UnitTests/View/Layout/ToScreenTests.cs

@@ -334,9 +334,9 @@ public class ToScreenTests (ITestOutputHelper output)
             X = 1,
             Y = 1,
             Width = 10,
-            Height = 10,
-            ContentSize = new (20, 20)
+            Height = 10
         };
+        view.SetContentSize (new (20, 20));
 
         Point testPoint = new (0, 0);
         Assert.Equal (new Point (1, 1), view.ContentToScreen (testPoint));
@@ -362,7 +362,7 @@ public class ToScreenTests (ITestOutputHelper output)
 
         var view = new View ();
         view.Frame = frame;
-        view.ContentSize = new (20, 20);
+        view.SetContentSize (new (20, 20));
         view.BorderStyle = LineStyle.Single;
 
         // Act
@@ -403,7 +403,7 @@ public class ToScreenTests (ITestOutputHelper output)
 
         var view = new View ();
         view.Frame = frame;
-        view.ContentSize = new (20, 20);
+        view.SetContentSize (new (20, 20));
 
         superView.Add (view);
         superView.LayoutSubviews ();
@@ -608,7 +608,7 @@ public class ToScreenTests (ITestOutputHelper output)
 
     //    var view = new View ();
     //    view.Frame = frame;
-    //    view.ContentSize = new (11, 11);
+    //    view.SetContentSize (new (11, 11));
     //    view.Content = view.Content with { Location = new (1, 1) };
 
     //    superView.Add (view);
@@ -928,7 +928,7 @@ public class ToScreenTests (ITestOutputHelper output)
 
         var view = new View ();
         view.Frame = frame;
-        view.ContentSize = new (11, 11);
+        view.SetContentSize (new (11, 11));
         view.Viewport = view.Viewport with { Location = new (1, 1) };
 
         superView.Add (view);

+ 1 - 1
UnitTests/View/Layout/ViewportTests.cs

@@ -279,7 +279,7 @@ public class ViewportTests (ITestOutputHelper output)
     {
         // Arrange
         var view = new View ();
-        view.ContentSize = new Size (100, 100);
+        view.SetContentSize (new (100, 100));
         var newViewport = new Rectangle (0, 0, 200, 200);
         view.ViewportSettings = ViewportSettings.AllowLocationGreaterThanContentSize;
 

+ 7 - 7
UnitTests/Views/ProgressBarTests.cs

@@ -20,7 +20,7 @@ public class ProgressBarTests
                       new Attribute (pb.ColorScheme.HotNormal.Foreground, pb.ColorScheme.HotNormal.Background)
                      );
         Assert.Equal (Colors.ColorSchemes ["Base"].Normal, pb.ColorScheme.Normal);
-        Assert.Equal (1, pb.Height);
+        Assert.Equal (1, pb.Frame.Height);
         Assert.Equal (ProgressBarStyle.Blocks, pb.ProgressBarStyle);
         Assert.Equal (ProgressBarFormat.Simple, pb.ProgressBarFormat);
         Assert.Equal (CM.Glyphs.BlocksMeterSegment, pb.SegmentCharacter);
@@ -111,17 +111,17 @@ public class ProgressBarTests
 
         pb1.ProgressBarFormat = ProgressBarFormat.Simple;
         Assert.Equal (ProgressBarFormat.Simple, pb1.ProgressBarFormat);
-        Assert.Equal (1, pb1.Height);
+        Assert.Equal (1, pb1.Frame.Height);
         pb2.ProgressBarFormat = ProgressBarFormat.Simple;
         Assert.Equal (ProgressBarFormat.Simple, pb2.ProgressBarFormat);
-        Assert.Equal (1, pb2.Height);
+        Assert.Equal (1, pb2.Frame.Height);
 
         pb1.ProgressBarFormat = ProgressBarFormat.SimplePlusPercentage;
         Assert.Equal (ProgressBarFormat.SimplePlusPercentage, pb1.ProgressBarFormat);
-        Assert.Equal (1, pb1.Height);
+        Assert.Equal (1, pb1.Frame.Height);
         pb2.ProgressBarFormat = ProgressBarFormat.SimplePlusPercentage;
         Assert.Equal (ProgressBarFormat.SimplePlusPercentage, pb2.ProgressBarFormat);
-        Assert.Equal (1, pb2.Height);
+        Assert.Equal (1, pb2.Frame.Height);
     }
 
     [Fact]
@@ -131,10 +131,10 @@ public class ProgressBarTests
         var pb = new ProgressBar ();
 
         pb.ProgressBarFormat = ProgressBarFormat.Simple;
-        Assert.Equal (1, pb.Height);
+        Assert.Equal (1, pb.Frame.Height);
 
         pb.ProgressBarFormat = ProgressBarFormat.SimplePlusPercentage;
-        Assert.Equal (1, pb.Height);
+        Assert.Equal (1, pb.Frame.Height);
     }
 
     [Fact]

+ 17 - 11
UnitTests/Views/ScrollViewTests.cs

@@ -11,7 +11,8 @@ public class ScrollViewTests
     [Fact]
     public void Adding_Views ()
     {
-        var sv = new ScrollView { Width = 20, Height = 10, ContentSize = new (30, 20) };
+        var sv = new ScrollView { Width = 20, Height = 10 };
+        sv.SetContentSize (new (30, 20));
 
         sv.Add (
                 new View { Width = 10, Height = 5 },
@@ -184,9 +185,9 @@ public class ScrollViewTests
             Y = 3,
             Width = 10,
             Height = 10,
-            ContentSize = new (23, 23),
             KeepContentAlwaysInViewport = false
         };
+        sv.SetContentSize (new (23, 23));
         var bottomLabel = new Label { X = 15, Y = 15, Text = "At 15,15" };
         var top = new Toplevel ();
         top.Add (topLabel, sv, bottomLabel);
@@ -375,9 +376,9 @@ public class ScrollViewTests
             Y = 1,
             Width = 10,
             Height = 5,
-            ContentSize = size,
             ColorScheme = new ColorScheme { Normal = new Attribute (Color.Red, Color.Green) }
         };
+        sv.SetContentSize (size);
         string text = null;
 
         for (var i = 0; i < size.Height; i++)
@@ -444,15 +445,17 @@ public class ScrollViewTests
     {
         var sv = new ScrollView
         {
-            Width = 10, Height = 10, ContentSize = new (50, 50), ContentOffset = new (25, 25)
+            Width = 10, Height = 10,
         };
+        sv.SetContentSize (new (50, 50));
+        sv.ContentOffset = new (25, 25);
 
         var top = new Toplevel ();
         top.Add (sv);
         Application.Begin (top);
 
-        Assert.Equal(new(-25,-25),sv.ContentOffset);
-        Assert.Equal(new(50,50),sv.ContentSize);
+        Assert.Equal (new (-25, -25), sv.ContentOffset);
+        Assert.Equal (new (50, 50), sv.ContentSize);
         Assert.True (sv.AutoHideScrollBars);
         Assert.True (sv.ShowHorizontalScrollIndicator);
         Assert.True (sv.ShowVerticalScrollIndicator);
@@ -478,7 +481,8 @@ public class ScrollViewTests
     [AutoInitShutdown]
     public void ContentSize_AutoHideScrollBars_ShowHorizontalScrollIndicator_ShowVerticalScrollIndicator ()
     {
-        var sv = new ScrollView { Width = 10, Height = 10, ContentSize = new (50, 50) };
+        var sv = new ScrollView { Width = 10, Height = 10, };
+        sv.SetContentSize (new (50, 50));
 
         var top = new Toplevel ();
         top.Add (sv);
@@ -539,10 +543,10 @@ public class ScrollViewTests
             Y = 1,
             Width = 15,
             Height = 10,
-            ContentSize = size,
             ShowHorizontalScrollIndicator = true,
             ShowVerticalScrollIndicator = true
         };
+        scrollView.SetContentSize (size);
         scrollView.Add (view);
         var win = new Window { X = 1, Y = 1, Width = 20, Height = 14 };
         win.Add (scrollView);
@@ -866,8 +870,8 @@ public class ScrollViewTests
             Y = 3,
             Width = 10,
             Height = 10,
-            ContentSize = new (50, 50)
         };
+        sv.SetContentSize (new (50, 50));
 
         for (var i = 0; i < 8; i++)
         {
@@ -916,7 +920,8 @@ public class ScrollViewTests
     [Fact]
     public void KeyBindings_Command ()
     {
-        var sv = new ScrollView { Width = 20, Height = 10, ContentSize = new (40, 20) };
+        var sv = new ScrollView { Width = 20, Height = 10, };
+        sv.SetContentSize (new (40, 20));
 
         sv.Add (
                 new View { Width = 20, Height = 5 },
@@ -1050,7 +1055,8 @@ public class ScrollViewTests
     [AutoInitShutdown]
     public void Remove_Added_View_Is_Allowed ()
     {
-        var sv = new ScrollView { Width = 20, Height = 20, ContentSize = new (100, 100) };
+        var sv = new ScrollView { Width = 20, Height = 20, };
+        sv.SetContentSize (new (100, 100));
 
         sv.Add (
                 new View { Width = Dim.Fill (), Height = Dim.Fill (50), Id = "View1" },

+ 3 - 3
UnitTests/Views/SliderTests.cs

@@ -514,7 +514,7 @@ public class SliderTests
 
         Assert.Equal (new (6, 2), expectedSize);
 
-        view.ContentSize = new (1, 1);
+        view.SetContentSize (new (1, 1));
 
         view.LayoutSubviews ();
         slider.SetRelativeLayout (view.Viewport.Size);
@@ -548,7 +548,7 @@ public class SliderTests
 
         Assert.Equal (new (6, 10), expectedSize);
 
-        view.ContentSize = new (1, 1);
+        view.SetContentSize (new (1, 1));
 
         view.LayoutSubviews ();
         slider.SetRelativeLayout (view.Viewport.Size);
@@ -582,7 +582,7 @@ public class SliderTests
 
         Assert.Equal (new (10, 2), expectedSize);
 
-        view.ContentSize = new (1, 1);
+        view.SetContentSize (new (1, 1));
 
         view.LayoutSubviews ();
         slider.SetRelativeLayout (view.Viewport.Size);

+ 1 - 1
UnitTests/Views/ToplevelTests.cs

@@ -1320,8 +1320,8 @@ public class ToplevelTests
             Y = 3,
             Width = 40,
             Height = 16,
-            ContentSize = new (200, 100)
         };
+        scrollView.SetContentSize (new (200, 100));
         var win = new Window { X = 3, Y = 3, Width = Dim.Fill (3), Height = Dim.Fill (3), Arrangement = ViewArrangement.Movable };
         scrollView.Add (win);
         Toplevel top = new ();