在禁用 RealTimeStylus 的情况下,在 WPF 应用程序中触摸滚动 ScrollViewer [英] Touch Scrolling ScrollViewer in WPF App with RealTimeStylus Disabled

查看:74
本文介绍了在禁用 RealTimeStylus 的情况下,在 WPF 应用程序中触摸滚动 ScrollViewer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发一个 WPF 4.5 应用程序,该应用程序将在带有触摸屏显示器的 Windows 8 计算机上运行.

We are working on a WPF 4.5 application that will be run on Windows 8 computers with touchscreen monitors.

我们已按照 MSDN 上的说明禁用对 RealTimeStylus 的支持,因为我们有一些视图需要通过 WM_TOUCH 支持多点触控.

We have disabled support for the RealTimeStylus following the directions on the MSDN, since we have some views that need multitouch support through WM_TOUCH.

问题是禁用 RealTimeStylus 支持似乎也禁用了用户使用触摸滚动 ScrollViewer 的能力 - 通常用户可以用手指在 ScrollViewer 周围平移,但如果禁用 RealTimeStylus 支持,似乎不可能做到这.ScrollViewer 的 PanningMode 设置为Both".

The problem is that disabling the RealTimeStylus support seems to also disable the user's ability to scroll a ScrollViewer using touch - normally the user can pan around ScrollViewers with their fingers, but if RealTimeStylus support is disabled, it does not seem possible to do this. The ScrollViewer's PanningMode is set to "Both".

是否可以在 WPF 应用程序中组合这些东西,或者它们是相互排斥的?

Is it possible to combine these things in a WPF application, or are they mutually exclusive?

推荐答案

另一种选择是在内容周围添加箭头按钮.我们已经在触摸屏信息亭上使用了这一点.这需要更多的工作,但可以制作成自定义控件.我唯一支持垂直滚动的代码.

Another option is to add arrow buttons around the content. We've used this to great effect on a touch screen kiosk. It's a bit more work, but could be made into a custom control. The only code I have supports vertical scrolling.

添加水平滚动也应该很容易.在下面的代码中,滚动条上方和下方有两个按钮,分别称为 Less 和 More.

It should be easy enough to add horizontal scrolling as well. In the code below, there are two buttons, called Less and More above and below the scroller.

    double Epsilon = .001;

    private void Scroller_ScrollChanged(object sender, ScrollChangedEventArgs e)
    {
        if ( Scroller.ScrollableHeight > 0 ) {
            Less.Visibility = Math.Abs(Scroller.VerticalOffset - 0) > Epsilon ? Visibility.Visible : Visibility.Hidden;
            More.Visibility = Scroller.VerticalOffset + Scroller.ViewportHeight < Scroller.ExtentHeight ? Visibility.Visible : Visibility.Hidden;
        } else {
            Less.Visibility = More.Visibility = Visibility.Hidden;
        }

        if (Scroller.ExtentHeight / Scroller.ViewportHeight > 2)
        {
            SearchPanel.Visibility = Visibility.Visible;
        }
    }

    private void Less_Click(object sender, RoutedEventArgs e)
    {
        Sounds.Click();
        Scroller.PageUp();
    }

    private void More_Click(object sender, RoutedEventArgs e)
    {
        Sounds.Click();
        Scroller.PageDown();
    }

这篇关于在禁用 RealTimeStylus 的情况下,在 WPF 应用程序中触摸滚动 ScrollViewer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆