0

I am new when it comes to programming in C# and UWP. For my school project I need to implement a feature like mouse click event of both left click and right click at the same time in my C#.

For this project, I had to use both UWP and WinForms for the views, in which I need to create one for each, however I have no idea how to implement the double click (by double I mean tapping both the left mouse button and right mouse button) at the same time. Is it possible?

Ola Ström
  • 4,136
  • 5
  • 22
  • 41
  • UWP has `DoubleTapped` event, so you can use it directly. In WinForm, `DoubleClick` event is not suggested. But you can implement it through https://stackoverflow.com/questions/13486245/winforms-how-to-call-a-double-click-event-on-a-button/13486487 – Vincent May 19 '20 at 01:54

1 Answers1

1

For implementing mouse click within UWP platform, you could refer this document. Most Mouse input can be handled through the common routed input events supported by all UIElement objects.

<Grid Background="Aqua"
    DoubleTapped="Grid_DoubleTapped"
    RightTapped="Grid_RightTapped"
    Tapped="Grid_Tapped"
    >
    <TextBlock
        x:Name="InfoTextBlock"
        HorizontalAlignment="Left"
        VerticalAlignment="Top"
        />
</Grid>

Code Behind

private void Grid_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
{
    InfoTextBlock.Text = "Double Click";
}

private void Grid_RightTapped(object sender, RightTappedRoutedEventArgs e)
{
    InfoTextBlock.Text = "Right Click";
}

private void Grid_Tapped(object sender, TappedRoutedEventArgs e)
{
    InfoTextBlock.Text = "Left Click";
}

For WinForm, please check this document.

Nico Zhu
  • 32,367
  • 2
  • 15
  • 36