I would like to perform some processing from the right-click context menu, depending on the coordinates or element clicked.

ichiro kanazawa 80 Reputation points
2023-08-13T01:37:33.19+00:00

Thank you for reading my post.

I have a question in a .net Mau iblazor program.

I would like to perform some processing from the right-click context menu, depending on the coordinates or element clicked.

Specifically, I want to control the style of the clicked element with CSS.

With onmousedown etc., you can pass the index to the argument of the event function, but I would like to do the same from the right-click menu.

I am referring to the following.

https://learn.microsoft.com/ja-jp/dotnet/maui/user-interface/context-menu

Developer technologies | .NET | Blazor
Developer technologies | .NET | .NET MAUI
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,126 Reputation points Microsoft External Staff
    2023-08-14T05:27:58.0166667+00:00

    Hello,

    After investigation and testing, this feature was not possible for the following reasons:

    • Unable to get the DOM element from the MenuFlyoutItem event when right clicked.
    • CSS style changes to HTML elements cannot be done in MenuFlyoutItem event.

    For this feature, it is recommended that you implement an HTML-based right-click menu in your blazor page and complete styling changes to page elements through onmousedown event and Javascript.

    Please refer to ASP.NET Core Blazor JavaScript interoperability for more details about how to invoke JS in Blazor.

    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.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

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.