I've developed an extension some time ago that allows to highlight a section of the scrollbar with the specified color, here is how I do it:
/// <summary>On layout changed analyze the regions and lines and highlight them on the scroll bar if needed.</summary>
private void OnLayoutChanged(object sender, TextViewLayoutChangedEventArgs e)
{
Children.Clear();
int n = AllAdornments.TextAdornment.Regions.Length;
for (int i = 0; i < n; i++)
{
if (AllAdornments.TextAdornment.Regions[i].Adornment != null
&& AllAdornments.TextAdornment.Regions[i].EndLine < e.NewSnapshot.LineCount)
{
var rect = new Rectangle();
var firstLine = e.NewSnapshot.GetLineFromLineNumber(AllAdornments.TextAdornment.Regions[i].StartLine);
var lastLine = e.NewSnapshot.GetLineFromLineNumber(AllAdornments.TextAdornment.Regions[i].EndLine);
double top, bottom;
double firstLineTop;
MapLineToPixels(firstLine, out firstLineTop, out bottom);
SetTop(rect, firstLineTop);
SetLeft(rect, ScrollBarLeftPadding);
MapLineToPixels(lastLine, out top, out bottom);
rect.Height = bottom - firstLineTop;
rect.Width = ScrollBarWidth;
Color color = Communicator.LerpColor(AllAdornments.TextAdornment.UserBackgroundCol,
AllAdornments.TextAdornment.Regions[i].Adornment.Color, ScrollBarIntensity
* AllAdornments.TextAdornment.Regions[i].Adornment.IntensityMult);
color.A = ScrollBarOpacity;
rect.Fill = new SolidColorBrush(color);
Children.Add(rect);
}
}
}
Here is how it looks in Visual Studio:
This worked perfectly for a long time (around 1,5 - 2 years), but when I updated VS four months ago a problem emerged: I can no longer click on the section of the scrollbar margin with the colored Rectangle - the mouse click simply does nothing as long as it is above the colored Rectangle. On the empty section of the scrollbar it works as usual. Before I could not only click on my Rectangle-s, but hold the mouse button down and drag the scrollbar. Is there any way I can bring back this functionality?
Can you try setting rect.IsHitTestVisible = false;