diff --git a/Terminal.Gui/Views/TreeView.cs b/Terminal.Gui/Views/TreeView.cs
index 67109385b..af0a4ab90 100644
--- a/Terminal.Gui/Views/TreeView.cs
+++ b/Terminal.Gui/Views/TreeView.cs
@@ -262,6 +262,12 @@ namespace Terminal.Gui {
///
public bool InvertExpandSymbolColors {get;set;}
+ ///
+ /// True to leave the last row of the control free for overwritting (e.g. by a scrollbar). When True scrolling will be triggered on the second last row of the control rather than the last.
+ ///
+ ///
+ public bool LeaveLastRow {get;set;}
+
}
///
@@ -792,16 +798,17 @@ namespace Terminal.Gui {
var newIdx = Math.Min(Math.Max(0,idx+offset),map.Length-1);
SelectedObject = map[newIdx].Model;
+ /*this -1 allows for possible horizontal scroll bar in the last row of the control*/
+ int leaveSpace = Style.LeaveLastRow ? 1 :0;
if(newIdx < ScrollOffsetVertical) {
//if user has scrolled up too far to see their selection
ScrollOffsetVertical = newIdx;
}
- else if(newIdx >= ScrollOffsetVertical + Bounds.Height -1 /*this -1 allows for possible horizontal scroll bar*/){
+ else if(newIdx >= ScrollOffsetVertical + Bounds.Height - leaveSpace){
//if user has scrolled off bottom of visible tree
- ScrollOffsetVertical = Math.Max(0,(newIdx+1) - (Bounds.Height-1));
-
+ ScrollOffsetVertical = Math.Max(0,(newIdx+1) - (Bounds.Height-leaveSpace));
}
}
diff --git a/UICatalog/Scenarios/TreeViewFileSystem.cs b/UICatalog/Scenarios/TreeViewFileSystem.cs
index b9ac80a5c..3306d43ce 100644
--- a/UICatalog/Scenarios/TreeViewFileSystem.cs
+++ b/UICatalog/Scenarios/TreeViewFileSystem.cs
@@ -83,6 +83,9 @@ namespace UICatalog.Scenarios {
private void SetupScrollBar ()
{
+ // When using scroll bar leave the last row of the control free (for over-rendering with scroll bar)
+ treeViewFiles.Style.LeaveLastRow = true;
+
var _scrollBar = new ScrollBarView (treeViewFiles, true);
_scrollBar.ChangedPosition += () => {