Showing Context Menus for ListView Items
Environment
Version | Product | Author |
---|---|---|
4.0.0 | Telerik UI for .NET MAUI ListView | Dobrinka Yordanova |
Description
How can I add a context menu to a Telerik UI for .NET MAUI ListView item?
Solution
A possible approach to achieve the desired scenario is to use the Telerik UI for .NET MAUI Button and Popup control.
1. Create a business model for the items:
2. In the ViewModel
, create some sample names to populate the data source and add a command that will toggle the IsPopupOpen
property of that item (the command opens the context menu):
3. Add the code in XAML. It uses a RadPopup
in the ItemTemplate
with a slight offset and provides the takeaways:
- The
IsOpen
property of the control is bound to theIsPopupOpen
property of the model. - The
Command
of the Button usesx:Reference
to get to thecommand
property of theViewModel
.
The following image shows the final result.