Hello,
MAUI's internal controls do not need AddHandler
to register because the handlers of these internal controls have been designed by the developer, and MAUI knows what handlers these controls correspond to after initialization, so no additional registration is required.
For your custom control, MAUI needs to use the AddHandler method to understand what the handler corresponds to.
Please refer to Create a custom control using handlers - Register the handler for more details.
A custom control and its handler must be registered with an app, before it can be consumed. This should occur in the
CreateMauiApp
method in theMauiProgram
class in your app project, which is the cross-platform entry point for the app.
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.