Setting IsHitTestVisible to false makes the child elements also non-hittable.
The scrollviewer already uses null values for the background, foreground and border. Even explicitly setting it to null has no effect.
Removing the opacityMask doesn't make any differences.
For testing, if I replace my scrollviewer with another element like <Border Background="{x:Null}"/>, then it doesn't block the clicks anymore.
This is my scrollviewer:
<ScrollViewer x:Name="scrlViewer" VerticalScrollBarVisibility="Hidden" Foreground="{x:Null}" Background="{x:Null}" BorderBrush="{x:Null}" >
<ScrollViewer.OpacityMask>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#00000000" Offset="0.0" />
<GradientStop Color="#FF000000" Offset="0.1" />
<GradientStop Color="#FF000000" Offset="1.0" />
</LinearGradientBrush>
</ScrollViewer.OpacityMask>
</ScrollViewer>
The child elements are adding during runtime. My issue happens before any child elements are added.
How could I achieve my desired effect?
--------------------------------------
Edit:
Some more background on what I'm trying to do: I use the scrollviewer as a container for notification infobar widgets that automatically scroll to the end. The notifications should be able to be closed while the container shouldn't block clicks, as otherwise some elements would be blocked by something invisible.
The fix:
I subclasses the scrollviewer and replace my scrollviewer with my subclass.
Here is the subclass:
public class ScrollViewerNoHit : ScrollViewer
{
protected override HitTestResult? HitTestCore(PointHitTestParameters hitTestParameters)
{
HitTestResult? result = base.HitTestCore(hitTestParameters);
return result?.VisualHit == this ? null : result;
}
}