One 、 Preface

I'm used to it WPF、WinForm in “ Everything can be clicked ” The way .

But in MAUI But not in the middle .

stay MAUI in , Click on 、 Double click effect , It needs to pass “ Gesture recognizer ” To achieve .

This article , We'll pass “ Gesture recognizer ” for Label、Image Wait for the control to realize the click event .

I believe that after watching you , There must be gains !

This paper addresses :https://www.cnblogs.com/lesliexin/p/16433623.html


Two 、 Gesture recognizer

The recognizer used in this paper is :TapGestureRecognizer

Its introduction is as follows :

See :https://docs.microsoft.com/en-us/dotnet/maui/fundamentals/gestures/tap


3、 ... and 、 Realization

1, establish MAUI project

The creation process is not repeated , according to VS Prompt to create .

After creation , Some code will be attached by default , We carry out transformation based on it , Add a click event to it .

2, by Image Add click event

backstage CS The code is as follows :

3, by Label Add click event

backstage CS The code is as follows :

2, by Label Add double click event

Realization of double click effect , It mainly uses attributes “NumberOfTapsRequired”, The default value is 1, On behalf of click 1 Times can trigger .

We want to achieve double click effect , Set this property to 2.

backstage CS The code is as follows :


Four 、 demonstration

Compile run program , Let's click on the picture 、 label , You can see that the click event is triggered .

And the label “ Double click to display ”, No event is triggered at a single click , The event will only be triggered when double clicking .


5、 ... and 、 summary

Contact MAUI since , Found that in order to be compatible with cross platform , Especially compatible with mobile terminals , All functions are based on the mobile terminal with the smallest functional characteristics , This leads to the lack of desktop features , Although reasonable , But the desktop effect is really not good .

Of course , Also with me at present MAUI The lack of research is related to .

For now only , If I use MAUI To develop it , Only develop mobile software , Instead of developing desktop software .

My level is limited , It's hard to avoid omission , Readers are welcome to comment and correct .


-【END】-

【MAUI】 by Label、Image And other controls to add more related articles about click events

  1. Inherit UIView Add click events to the child controls of

    UITapGestureRecognizer*tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:selfaction:@select ...

  2. ios Add a click event to the mobile control

    Preface : Give me a UIView Do moving animation , Although it looks like frame Constantly changing , But it's frame It's the final value . In other words, the animation seen on the surface is an illusion , Its real position is already fixed . So only click on his real frame Fan ...

  3. android in RecyclerView Control to implement click events

    RecyclerView Control to achieve click events with ListView Controls are different , No similar setOnItemClickListener() This way of registering listeners , Instead, you need to register specific click events for subitems . Examples of this article ...

  4. Android Use the code to actively call the click event of the control ( Simulate human hands to touch controls )

    Use the code to actively call the click event of the control ( Simulate human hands to touch controls ) //View It can be LinearLayout,Button,TextView View.performClick();

  5. Android monitor Button and ImageButton Control's click event

    One .onClick event Button and ImageButton There is one. onClick event , Through self .setOnClickListener(OnClickListener) Method to add a click event All the controls are ...

  6. Android Add a click ripple effect to the control

    Android stay 5.0 The edition is Button The ripple effect when clicking is added by default , And you can easily achieve this cool effect on other controls . There are two kinds of ripple effects , A kind of ripple with boundary from time to time , Another kind of boundless ripples . The so-called boundary , Ripples ...

  7. Android ordinary ListViewDemo And click events for each control

    ListView What is it? ? ListView It's a Data controls , Can show data read from the database . yes .net3.5 New controls . It is better than gridview More flexible , And it supports multiple templates , Support paging . Article address http:// ...

  8. Android Skill gossip —— How to gracefully handle the click event of the control

    First, share a best practice : We develop more complex Android When applying, you often write a BaseActivity perhaps BaseFragment, There are some basic and common methods written in it , For example, monitoring network conditions . Pop-up dialog box . Set up ac ...

  9. Button Control's click event

    Java Code for Main points : findViewById(); OnClickListener() package com.example.admin.myapplication; import andr ...

  10. listview Click the event of the control in the adapter and pass the value

    @Override public View getView(final int position, View convertView, ViewGroup parent) { // TODO Auto ...

Random recommendation

  1. Enterprise Solution Inventory management software C/S framework , Support 64 Bit system logistics , Capital flow , Information flow is fully integrated

          location   Target Customers Small and medium-sized manufacturing enterprises , Wholesale and retail , Trading enterprises The main module Modules purchase . sales . stock . Four modules of financial accounts , Including sales in the process of enterprise operation . purchase . Inventory positions need ...

  2. Codeforces Round #380(div 2)

    A. The question : Here's a string (<=100), take ogo ogogo ogogogo ogogogogo…… This is all reduced to ***, Output the condensed string analysis : The first sweep is for those go The location of , Record next[i] ...

  3. Java Medium wait and sleep

    sleep() and wait() First ,Java Multithreading in is a preemptive mechanism , Not a time-sharing mechanism . The preemptive mechanism is that there are multiple threads in the runnable state , But only one thread is running . This mechanism determines , Multithreaded access to the same object , have to ...

  4. OOD meditations --- The relationship between classes and objects --- Inclusion relation 3

    4.7 Class should not contain more objects than the developer's short-term memory , This number should usually be 6 about 4.8 Let the system be vertically distributed in a narrow and deep inclusion system Suppose there are two menus : Dinner ---> melon ---> The steak ---& ...

  5. eclipse Zhongjian python Project and run

    1. Help → Install New Software 2.Enter http://pydev.org/updates 3. Click on Click "Next" and " ...

  6. VirtualBox No, 64 Bit options , Unable to install 64 Bit solution (zhuan)

    http://www.askmaclean.com/archives/vbox-virtualbox-64-bit.html ************************************* ...

  7. One 、 Socket And UDP Transfer files asynchronously

    use SCOKET Sending files is a difficult problem , Online examples are also very simple , I'm going to write a perfect example , This is the beginning , Later ones will be modified on the basis of this example , Prepare to implement multi-threaded transmission . The completion of breakpoint transmission and file transmission ...

  8. Cluster technology ( Two ) MySQL Cluster introduction and configuration details

    when?why? use MySQL colony ? Reduce data center node pressure and large data processing ( Read / write separation ), Use the handle MySQL Distribution , One or more application Corresponding to one MySQL database . How many MySQL Database public data ...

  9. git appear : not a git repository

    Use git add . There is such a mistake : fatal: not a git repository (or any of the parent directories): .git mean :.git no ...

  10. 51nod 1476 The minimum cost of bracket sequence ( greedy + Priority queue )

    The question We have a kind of only "(",")" and "?" A sequence of parentheses , You have to "?" Replace with parentheses , So we can get a legal sequence of parentheses . about ...