in Education by
I'm writing an app for Android in Xamarin Forms. I want to navigate the user from one page to another, when user clicks an "EditList" button (middle one), but at the same time I want to pass an argument of specific type: "ShoppingList", which I get from ListView's ItemSelected event in order to display it's contents on the next Page. The problem is - the only way I can get that value is when the item in listview is clicked. How can I get that listview item clicked value from within the button, without having to click on the listview item beforehand? How it looks Also here's the Page for reference. ListView with ShoppingList items I'm using Navigation.PushAsync(), where I also pass a ShoppingListDetailViewModel and inject the item from SelectedItem OnItemSelected Here is ListView's OnItemSelected event handler for ItemSelected event: async void OnItemSelected(object sender, SelectedItemChangedEventArgs args) { var item = args.SelectedItem as ShoppingList; if (item == null) return; await Navigation.PushAsync(new ShoppingListDetailPage(new ShoppingListDetailViewModel(item))); // Manually deselect item. ItemsListView.SelectedItem = null; } (ItemsListView is my ListView's name defined in XAML like that x:Name="ItemsListView") I've tried to make Command which would maybe pass a Shopping List object through Command parameter but I got confused with all that, and I think that there must be simpler solution for doing this wich I just can't see. XAML This is my XAML Page with the ListView and button inside it:

1 Answer

0 votes
by
assign the value of the current item in the list to the Button's CommandParameter then in your handler public void EditListButton_Clicked(object sender, EventArgs args) { ImageButton btn = (ImageButton)sender; var item = (ShoppingList)btn.CommandParameter; if (item == null) return; await Navigation.PushAsync(new ShoppingListDetailPage(new ShoppingListDetailViewModel(item))); }

Related questions

0 votes
    I'm writing an app for Android in Xamarin Forms. I want to navigate the user from one page to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    I'm writing an app for Android in Xamarin Forms. I want to navigate the user from one page to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I'm making a drag and drop game for my A level computing coursework. My drag and drop works fine, but I have 6 ... >= 190 && theButton.Location.X = 42 && theButton.Location.Y...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I have a generic method defined like this: public void MyMethod(T myArgument) The first thing I want to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    I have a generic method defined like this: public void MyMethod(T myArgument) The first thing I want to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    I have a generic method defined like this: public void MyMethod(T myArgument) The first thing I want to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    I have a generic method defined like this: public void MyMethod(T myArgument) The first thing I want to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    In C, how can i pass more than one argument to a thread? Normally, I do it in a way like, ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 11, 2022 in Education by JackTerrance
0 votes
    How will you navigate from one view to another view in MVC? Explain with a hyperlink example...
asked Jun 14, 2021 in Technology by JackTerrance
0 votes
    I am trying to call a method from the script Dice and after that method is executed the value of ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I'm working on an extension (BHO) for Internet Explorer, and having trouble attaching a .NET delegate to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I have one aspx page with 1000 anchor tag. I want to open single popup onclick of anchor tag & ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 20, 2022 in Education by JackTerrance
0 votes
    I have a web page that accepts an excel file, reads data from it and stores it in a buffer table ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    How do we pass command line argument in Eclipse? (a) Arguments tab (b) Variable tab (c) Cannot ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    How to pass a map from controller to javascript function in VF page?...
asked Dec 10, 2020 in Technology by JackTerrance
...