0

I hope someone can help me, I'm new in Avalonia World and I came from WPF World. I need to develop a basic Windows App in Multi-Touch, specifically I need to develop two (or more) buttons and other items, in multi-touch. How can I properly do that, so the buttons can be touched at the same time? (I mean that two buttons can be pressed at the same time on a touchscreen)

I'm using .NET 7 and C#

For now, I tried to follow this Avalonia's guide Multi-Touch but on this way, I can only manipulate multi-touch images, so I follow Custom Controls guide src/Avalonia.Samples/CustomControls/RatingControlSample and I tried to transform buttons reactive as an image to enable multiple recognizers touch events, with no success, is there someone can help me please?

2
  • What exactly do you mean with "buttons can be touched at the same time"? Do you want to have two Buttons in the pressed state at the same time?
    – Clemens
    Commented Jul 8 at 8:05
  • 1
    Yes, I mean that two buttons can be pressed at the same time on a touchscreen Commented Jul 8 at 8:10

1 Answer 1

0

I solved it thanks to a user on official telegram group! I'll leave their response below if anyone needs help in the future:

"It wouldnt surprise me this is because of the input focus changing when you press buttons. Only one thing can have focus afaik I.e. try setting the focusable property of the buttons to false".

It works well for me this is my axaml code sample:

<!-- 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>

Not the answer you're looking for? Browse other questions tagged or ask your own question.