1
我有一個類處理滾動條PreviewMouseWheel事件,它放大時間軸控件,並且一切都很完美,除了我必須在滾動條上進行clr +鼠標縮放以在視覺上更改滾動條縮略圖的狀態。我在時間線控件中實現了相同的PreviewMouseWheel事件,該事件對其datacontext具有不同的類,該類放大但不直觀地更新相鄰的滾動條控件。在整個窗口中處理clr + mouse的最佳方法是什麼?如何跨控件同步Ctrl +鼠標滾輪?
public void ZoomScrollbar_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
FrameworkElement el;
el = (FrameworkElement)sender;
if (Keyboard.Modifiers == ModifierKeys.Control)
{
var newValue = InitialZoomValue;
if(e.Delta > 0)
{
newValue += 1;
}
else
{
newValue -= 1;
}
OnZoomScroll(newValue);
InitialZoomValue = newValue;
}
}
<Style x:Key="TimelineToolboxStyle" TargetType="{x:Type controls:TimelineToolbox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:TimelineToolbox}">
<Grid x:Name="MainGrid">
<Grid.RowDefinitions>
<RowDefinition Height="10" />
<RowDefinition Height="*" />
<RowDefinition Height="10" />
</Grid.RowDefinitions>
<ScrollBar x:Name="ZoomScrollbar"
Grid.Row="1"
Minimum="1"
Maximum="12"
Value="{TemplateBinding InitialZoomValue}"
SmallChange="1"
Style="{DynamicResource ZoomScrollBarStyle}"
BorderThickness="9,0"
Width="22"
Margin="0"
BorderBrush="{x:Null}"
Background="Black"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
有什麼想法嗎? –