How to disable scrolling in ScrollViewer while Ctrl is pressed
- by zunyite
I'd like to implement zoom function while Ctrl key is pressed.
But the MouseWheel event is not trigger while the mouse is over the ScrollView.
Is there any way to do it?
ps:SilverLight 4.0
<UserControl x:Class="SilverlightApplication11.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 Background="Gray"
MouseWheel="ScrollViewer_MouseWheel"
x:Name="scrollViewer">
<Rectangle Width="200"
Height="2000"
MouseWheel="ScrollViewer_MouseWheel"
Fill="AliceBlue" />
</ScrollViewer>
</Grid>
private void ScrollViewer_MouseWheel(object sender, MouseWheelEventArgs e)
{
if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
{
zoom+=0.1;
e.Handled = true;
}
}