【问题标题】:Windows Phone 8.1 ManipulationDelta EventWindows Phone 8.1 ManipulationDelta 事件
【发布时间】:2015-01-29 13:08:11
【问题描述】:

我真的对这个话题感到困惑。我发现的所有教程都没有,例如当有触摸输入工作时移动对象。例如,他们都做这样的事情:

Control.AddHandler(UIElement.ManipulationStartedEvent, new EventHandler
    <ManipulationStartedEventArgs>(Control_ManipulationStarted), true);

但是没有 ManipulationStartedEventArgs,VS2013 找不到,也没有办法添加 using 指令。这些教程是否过时?MS 是否改变了 ManipulationDelta 的工作方式?

再次使用 Properties 部分的 EventHandler 部分添加它不起作用,无论我尝试做什么,都不会触发任何事件。

【问题讨论】:

    标签: c# windows animation windows-phone-8.1 user-input


    【解决方案1】:

    要使操作生效,UI 元素必须将ManipulationMode 属性设置为其他,而不是NoneSystem 才能作为操作事件源;即,如果您希望事件在指针水平移动时触发,请将 ManipulationMode 设置为 TranslateX

    对于 Windows Universal 中的 UI 操作,您有 3 个事件:

    System.Windows.Input 命名空间下每个都有自己的 EventArgs

    但是,问题可能出在您使用的 UI 元素的类型上,而不是所有的接受/生成操作事件。

    不支持的 UI 元素示例:

    • WebView
    • (我预计 Canvas 但不确定,尚未测试)

    执行以下操作的 UI 元素示例:

    • Textblock
    • ListView

    【讨论】:

    • 缺少 ManipulationMode 属性。好像我完全忘记了这一点,但我不记得它是在教程中设置的。无论如何,现在一切都按预期工作。谢谢!
    • 很高兴我能帮上忙,还有一些 UIElements 的 ManipulationMode 默认设置为可以生成操作事件的东西。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    相关资源
    最近更新 更多