在 Avalonia 框架上启用和开发多点触控

问题描述 投票:0回答:1

我希望有人能帮助我,我是 Avalonia World 的新人,来自 WPF World。 我需要在多点触控中开发一个基本的 Windows 应用程序,特别是我需要在多点触控中开发两个(或更多)按钮和其他项目。我怎样才能正确地做到这一点,以便可以同时触摸按钮? (我的意思是可以在触摸屏上同时按下两个按钮)

我正在使用 .NET 7 和 C#

目前,我尝试遵循 Avalonia 的指南 多点触控 但这样,我只能操作多点触控图像,所以我遵循自定义控件指南 src/Avalonia.Samples/CustomControls/RatingControlSample 我尝试将按钮反应性转换为图像以启用多个识别器触摸事件,但没有成功,有人可以帮助我吗?

c# multi-touch avaloniaui avalonia
1个回答
0
投票

更新! 感谢官方电报群的一位用户,我解决了这个问题! 如果以后有人需要帮助,我会在下面留下他的回复: “我不会感到惊讶,这是因为按下按钮时输入焦点会发生变化。据我所知,只有一件事可以获得焦点 IE。尝试将按钮的可聚焦属性设置为 false”。 这对我来说很有效 这是我的 axaml 代码示例:

<!-- Create a sample button -->
<Button Name="ButtonDisplayed"
        Background="WhiteSmoke" Width="400" Height="140"
        HorizontalAlignment="Left" VerticalAlignment="Center"
        Margin="3" FontWeight="Bold" Foreground="MediumPurple"
        BorderBrush="MediumPurple"
        BorderThickness="4"
        Focusable="False"
        >
    <TextBlock Text="Touch Me" TextWrapping="Wrap" TextAlignment="Center" FontSize="35" />
</Button>
<!-- Create another sample button -->
<Button Name="ButtonClear"
        Background="WhiteSmoke" Width="400" Height="140"
        HorizontalAlignment="Right" VerticalAlignment="Center"
        Margin="3" FontWeight="Bold" Foreground="MediumPurple"
        BorderBrush="MediumPurple"
        BorderThickness="4"
        Focusable="False"
        >
    <TextBlock Text="Touch Me Too" TextWrapping="Wrap" TextAlignment="Center" FontSize="35" />
</Button>
© www.soinside.com 2019 - 2024. All rights reserved.