更新时间:2023-01-24 14:32:54
您可以使用 适用于 Windows Phone 7 的 Silverlight 控制工具包.在您的 UI 元素中,添加以下代码段(在您的 WP7 项目中引用工具包的 DLL 之后) -
You can use the GestureService
in the Silverlight Control Toolkit for Windows Phone 7. In your UI element, add the following piece of code (after you have referenced the toolkit's DLL in your WP7 project) -
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener Flick="OnFlick"/>
</toolkit:GestureService.GestureListener>
在代码隐藏文件中实现处理程序 OnFlick,就像这样 -
Implement the handler OnFlick in the code-behind file, like so -
private void OnFlick(object sender, FlickGestureEventArgs e)
{
var vm = DataContext as SelectedCatalogViewModel;
if (vm != null)
{
// User flicked towards left
if (e.HorizontalVelocity < 0)
{
// Load the next image
LoadNextPage(null);
}
// User flicked towards right
if (e.HorizontalVelocity > 0)
{
// Load the previous image
LoadPreviousPage();
}
}
}
希望这有帮助,indyfromoz
Hope this helps, indyfromoz