Changes SfListView

I would like to maintain the advantages of the SfListView but being able to use the native element of the listView.

What I mean is that the native XamarinForms listView when you do a longPress on an item, creates a bar with different options (see photo), however, the SfListView does not allow it. It only lets you create a small menu, but that's not what we're looking for.

A cordial greeting.


Attachment: Android_Emulator__pixel_2_q_10_0__api_29_5554_20220324_094249_5499acf7.zip

2 Replies

LN Lakshmi Natarajan Syncfusion Team March 28, 2022 02:57 AM UTC

Hi Cosme, 
 
The SfListView allows displaying a pop-up menu with different menu items to an item when it is long pressed by customizing the SfListView and by using custom view in it. 
 
Please refer to our online documentation to show context menu in SfListView from the following links, 
 
To show the menu to the entire width, set the HorizontalOption for the menu to FillAndExpand. Please refer to the following code snippets for more reference, 
 
private void ListView_ItemHolding(object sender, ItemHoldingEventArgs e) 
{ 
    item = e.ItemData as Contacts; 
    popupLayout = new SfPopupLayout(); 
    popupLayout.PopupView.HeightRequest = 50; 
    popupLayout.PopupView.HorizontalOptions = LayoutOptions.FillAndExpand; 
    popupLayout.PopupView.ContentTemplate = new DataTemplate(() => 
    { 
 
        var mainStack = new StackLayout() { Orientation = StackOrientation.Horizontal}; 
        mainStack.BackgroundColor = Color.Teal; 
 
        var deletedButton = new Button() 
        { 
            Text = "Delete", 
            HeightRequest=50, 
            BackgroundColor=Color.Teal, 
            TextColor = Color.White 
        }; 
        deletedButton.Clicked += DeletedButton_Clicked; 
        var sortButton = new Button() 
        { 
            Text = "Sort", 
            HeightRequest = 50, 
            BackgroundColor = Color.Teal, 
            TextColor=Color.White 
        }; 
        sortButton.Clicked += SortButton_Clicked; 
        mainStack.Children.Add(deletedButton); 
        mainStack.Children.Add(sortButton); 
        return mainStack; 
 
    }); 
    popupLayout.PopupView.ShowHeader = false; 
    popupLayout.PopupView.ShowFooter = false; 
 
    popupLayout.Show(0, 0); 
} 
 
 
 
 
We have attached the tested sample in the following links, 
 
Please let us know if this helps. 
 
Lakshmi Natarajan 
  
 



CM Cosme Morales Picon March 28, 2022 10:33 AM UTC

Thanks you.


Loader.
Up arrow icon