Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 75885

ListView Custom Cell Command Binding

$
0
0

Hi everyone!
I have a custom cell for my list view. Here are the codes. How Can I use the commands for itemselected event for my codes? Thanks!

My Custom Item Object

    public class customMenuObject
    {
        public string Name { get; set; }
        public string Detail { get; set; }
        public Command ObjectCommand { get; set; }

    }

My Custom Cell Class

public class CustomMenuCell : ViewCell
    {
        //I get Name and Detail bindings here. My problem is how can I get the ObjectCommand for this custom cell's itemselected event.
    }

An Example For Creating A Custom Cell

var menu_item_1 = new customMenuObject () { Name = "BUCKET", Detail = "BUCKET DETAIL", ObjectCommand = new Command (() => {
                masterDetailPage.mainNavPage.PushAsync (new bucketPage ());
                this.IsPresented = false;
            })};

I found the solution...

menuListView.ItemSelected += async (sender, e) => {
                var _selectedMenuItem = (customMenuObject)e.SelectedItem;
                _selectedMenuItem.ObjectCommand.Execute(this);
            };

Viewing all articles
Browse latest Browse all 75885

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>