【问题标题】:WPF C# Touch doens't work until the 11th touchWPF C# Touch 在第 11 次触摸之前不起作用
【发布时间】:2022-06-27 06:20:23
【问题描述】:

我为自助服务创建了一个 KIOSK 应用程序。产品列表以编程方式生成。在每个窗口上,程序都可以在触摸屏上正常工作。除了一个窗口,我必须在它开始工作之前准确地触摸 10 次。我试图重新制作那个窗口,我只在上面放了一个按钮,但它是一样的。如果我禁用手写笔并触摸支持: <AppContextSwitchOverrides value="Switch.System.Windows.Input.Stylus.DisableStylusAndTouchSupport=true"/> 比它有效。但这会禁用触摸滚动,这是良好的用户体验所必需的。 如果我使用 touchdown 或类似的东西,它可以工作,但我在那个窗口上有 CheckBoxRadioButton,我无法捕捉到任何触摸事件。有什么想法吗?

即使我从我的代码中清除所有内容,或者我创建一个具有相同名称的新窗口,它也不起作用...

这是我的 windows xml:

<Window x:Class="GestbalSelfSalePOS.ProdusComandaDetailsWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:GestbalSelfSalePOS"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        mc:Ignorable="d"
        Title="ProdusComandaDetailsWindow">
    <Grid>
        <Button Click="BackButton_Click" Content="Button" Margin="120"/>
    </Grid>
</Window>

我的客服:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace GestbalSelfSalePOS
{
    /// <summary>
    /// Interaction logic for ProdusComandaDetailsWindow.xaml
    /// </summary>
    public partial class ProdusComandaDetailsWindow : Window
    {
        public ProdusComandaDetailsWindow()
        {
            InitializeComponent();
        }

        private void BackButton_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}

这就是我打开这个窗口的方式:

new ProdusComandaDetailsWindow().ShowDialog();

【问题讨论】:

  • 请提供足够的代码,以便其他人更好地理解或重现问题。
  • 如何使用 snoop 之类的应用(或自行注册)来检查捕获事件的内容?
  • 我不知道那个应用,你能给我链接一下吗?

标签: c# wpf scroll touch stylus


【解决方案1】:

我正面临着完全相同的情况。我发现罪魁祸首是window.ShowDialog()。如果您尝试,仅用于测试,请仅使用 window.Show() 它将起作用。 在我看来,由于调用线程在 window.ShowDialog 上被阻塞,因此与触摸相关的事件不会被处理/重新路由。它与鼠标一起工作正常。 目前我没有找到解决方案,只是一种解决方法(一个令人讨厌的方法): 当我显示新窗口时,之前我在新窗口上设置了 Topmost=true,在父窗口上设置了 Topmost=false。我还在新窗口上将所有者设置为调用者,因此我可以在关闭新窗口之前将所有者 Topmost 设置为 true。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-06
    • 1970-01-01
    • 2015-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多