how to remove event handler in .net-android?

mc 5,266 Reputation points
2025-05-01T08:51:28.07+00:00

xxx.Click+=(sender,e)=>{};

how to remove it?

then I add another

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
4,090 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 121.4K Reputation points
    2025-05-01T09:40:13.86+00:00

    If the handler does not need to access local variables, then try to define functions:

    void Clicked1(object? sender, EventArgs e)
    {
       . . .
    }
    
    void Clicked2(object? sender, EventArgs e)
    {
       . . .
    }
    
    
    xxx.Clicked += Clicked1;
    . . .
    xxx.Clicked -= Clicked1;
    xxx.Clicked += Clicked2;
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.