0

我正在使用 WPF 并且我有一个 ScrollViewer 并且想要检测滚动条的水平移动。

我找到了这个,但不确定如何在我的 C# 代码中使用它。

http://msdn.microsoft.com/en-us/library/system.windows.forms.scrolleventargs.scrollorientation%28v=vs.85%29.aspx

我不想检测到我的 ScrollViewer 上的双击或单击,因为我将它用于其他用途。

 <ScrollViewer x:Name="coordinateScroll" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Margin="75,0,0,0" Width="1125" Height="750" Background="Transparent" MouseWheel="coordinateSystemBackground_MouseWheel" MouseDoubleClick="coordinateScroll_MouseDoubleClick " ScrollChanged="coordinateScroll_ScrollChanged" >
                    <Canvas x:Name="coordinateSystem" HorizontalAlignment="Left" VerticalAlignment="Top" Cursor="Cross" UseLayoutRounding="False"  Width="1125" Height="720" Background="Transparent" MouseWheel="coordinateSystemBackground_MouseWheel" >
                    </Canvas>
                </ScrollViewer>
4

1 回答 1

1

coordinateScroll_ScrollChangedXAML 中的事件有什么问题?

offset此处理程序将具有带有属性的事件参数。

 private void coordinateScroll_ScrollChanged(object sender, ScrollChangedEventArgs e)
 {
    var status = "ExtentHeight is now " + e.ExtentHeight.ToString();
    status += "\nExtentWidth is now " + e.ExtentWidth.ToString();
    status += "\nExtentHeightChange was " + e.ExtentHeightChange.ToString();
    status += "\nExtentWidthChange was " + e.ExtentWidthChange.ToString();
    status += "\nHorizontalOffset is now " + e.HorizontalOffset.ToString();
    status += "\nVerticalOffset is now " + e.VerticalOffset.ToString();
    status += "\nHorizontalChange was " + e.HorizontalChange.ToString();
    status += "\nVerticalChange was " + e.VerticalChange.ToString();
    MessageBox.Show(status);
}
于 2013-06-11T13:45:03.147 回答