我想在按住Ctrl鍵的同時實現縮放功能。 但鼠標懸停在ScrollView上時,MouseWheel事件不會觸發。如何在按住Ctrl的同時禁用ScrollViewer中的滾動
有沒有辦法做到這一點?
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;
}
}
@zunyite:請不要在標題中重複標記(「[Silverlight]」)。只要將它們留在標籤中即可。 – 2010-06-07 18:53:51