我不一定想使用滑块控件,而是让整个屏幕成为交互式滑块。例如,我正在练习床头柜应用程序,我喜欢它,所以他们可以向下滑动手指以降低亮度或向上滑动以增加亮度。我知道这已经在其他应用程序中完成,但我不知道从哪里开始。如果有人能给我一个关于什么技术可行的起点或任何实现这一点的想法,那就太棒了!
谢谢
答案 0 :(得分:3)
您可以使用Silverlight Toolkit中的GestureListener。看一下SL Toolkit提供的示例应用程序。有一个示例页面GestureSample.xaml。你会在那里找到如何检测手势。
答案 1 :(得分:1)
一种方法是使用Manipulation events。因此,例如,您在ManipulationStarted事件的ManipulationOrigin属性中获得起始位置。然后,您可以在ManipulationCompleted事件的操作属性中获得最终位置。提取两个Y
组件并检查它是否大于或小于零。如果它大于零,则用户向下移动,否则他们向上移动。
private void LayoutRoot_ManipulationStarted(object sender, System.Windows.Input.ManipulationStartedEventArgs e)
{
startY = e.ManipulationOrigin.Y;
}
private void LayoutRoot_ManipulationCompleted(object sender, System.Windows.Input.ManipulationCompletedEventArgs e)
{
endY = e.ManipulationOrigin.Y;
if(endY - startY > 0)
MessageBox.Text("Down")
else
MessageBox.Text("Up");
//add check to see if it equals zero in which case the user didn't swipe
}
或者,您可以使用Silverlight Toolkit或XNA Gestures执行类似的操作。 (它们两者略有不同)。