I have a problem with scrolling using mouse wheel in a scroll viewer. It seems that if the mouse cursor is over an area of the scrollbar that doesn't contain any ui element, scrolling doesn't work.
In the attached example I fill the scroll viewer with rectangle that have large margins. When the mouse cursor is over a rectangle scrolling works, but when it's over the margin, no scrolling occurs.
Any idea how to fix this?
XAML:
<UserControl x:Class="SilverlightApplication229.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel x:Name="MyPanel" />
</ScrollViewer>
</Grid>
</UserControl>
Code:
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
for (int i = 0; i < 100; i++)
{
Rectangle rect = new Rectangle { Width = 100, Height = 100, Fill = new SolidColorBrush(Colors.Red), Margin = new Thickness(50) };
MyPanel.Children.Add(rect);
}
}
}
Thanks!