diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs index c403bb8ac..5cceaa9b3 100644 --- a/Terminal.Gui/Views/ListView.cs +++ b/Terminal.Gui/Views/ListView.cs @@ -273,7 +273,10 @@ public class ListView : View } } - /// Gets or sets the item that is displayed at the top of the . + /// Gets or sets the index of the item that will appear at the top of the . + /// + /// This a helper property for accessing listView.Viewport.Y. + /// /// The top item. public int TopItem { @@ -285,13 +288,7 @@ public class ListView : View return; } - if (value < 0 || (_source.Count > 0 && value >= _source.Count)) - { - throw new ArgumentException ("value"); - } - Viewport = Viewport with { Y = value }; - SetNeedsDisplay (); } } diff --git a/Terminal.Gui/Views/ScrollBarView.cs b/Terminal.Gui/Views/ScrollBarView.cs index 308238544..008234cad 100644 --- a/Terminal.Gui/Views/ScrollBarView.cs +++ b/Terminal.Gui/Views/ScrollBarView.cs @@ -204,6 +204,11 @@ public class ScrollBarView : View get => _position; set { + if (_position == value) + { + return; + } + _position = value; if (IsInitialized) @@ -900,6 +905,10 @@ public class ScrollBarView : View // Helper to assist Initialized event handler private void SetPosition (int newPosition) { + if (newPosition < 0) + { + return; + } if (CanScroll (newPosition - _position, out int max, _vertical)) { if (max == newPosition - _position)