diff --git a/Terminal.Gui/View/Adornment/Adornment.cs b/Terminal.Gui/View/Adornment/Adornment.cs
index 210f625a9..addb02f2e 100644
--- a/Terminal.Gui/View/Adornment/Adornment.cs
+++ b/Terminal.Gui/View/Adornment/Adornment.cs
@@ -203,6 +203,10 @@ public class Adornment : View
/// if the specified Parent's SuperView-relative coordinates are within the Adornment's Thickness.
public override bool Contains (int x, int y)
{
+ if (Parent is null)
+ {
+ return false;
+ }
Rectangle frame = Frame;
frame.Offset (Parent.Frame.Location);
diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs
index ca1b1220a..c4b8cae8a 100644
--- a/Terminal.Gui/View/Layout/ViewLayout.cs
+++ b/Terminal.Gui/View/Layout/ViewLayout.cs
@@ -389,6 +389,14 @@ public partial class View
///
public Point GetViewportOffset () { return Padding is null ? Point.Empty : Padding.Thickness.GetInside (Padding.Frame).Location; }
+ ///
+ /// Gets or sets the size of the View's content. If the value is Size.Empty the size of the content is
+ /// the same as the size of the , and Viewport.Location will always be 0, 0.
+ /// If a positive size is provided, describes the portion of the content currently visible
+ /// to the view. This enables virtual scrolling.
+ ///
+ public Size ContentSize { get; set; }
+
#endregion Viewport
#region AutoSize
diff --git a/UnitTests/View/Layout/ViewportTests.cs b/UnitTests/View/Layout/ViewportTests.cs
index b95b1ffb6..3bab1959a 100644
--- a/UnitTests/View/Layout/ViewportTests.cs
+++ b/UnitTests/View/Layout/ViewportTests.cs
@@ -24,16 +24,16 @@ public class ViewportTests (ITestOutputHelper output)
var view = new View ();
view.Frame = frame;
- view.BeginInit();
- view.EndInit();
+ view.BeginInit ();
+ view.EndInit ();
// Act
var bounds = view.Viewport;
// Assert
- Assert.Equal(expectedW, bounds.Width);
+ Assert.Equal (expectedW, bounds.Width);
}
-
+
[Theory]
[InlineData (0, 0, 10)]
[InlineData (1, 0, 9)]
@@ -149,4 +149,15 @@ public class ViewportTests (ITestOutputHelper output)
// Assert
Assert.Equal (expectedW, bounds.Width);
}
+
+ [Fact]
+ public void ContentSize_Empty_ByDefault ()
+ {
+ View view = new ()
+ {
+ Width = 1,
+ Height = 1
+ };
+ Assert.Equal(Size.Empty, view.ContentSize);
+ }
}