Creating Page From ViewModel Using Button Within ListView

Hi there, I'm developing an app for a uni project and it's the versy first time for me developing an app.. I was able to put a Button in the list view and I'd like to call a new page for each listitem once the button is pressed..

var button = new Button
{
Text = "Add",
FontSize = Device.GetNamedSize(NamedSize.Micro,typeof(Button)),
HorizontalOptions = LayoutOptions.EndAndExpand,
VerticalOptions = LayoutOptions.Start
};
button.SetBinding(Button.CommandParameterProperty, new Binding("."));

            /* button.Clicked += async (sender, args) =>
             await Navigation.PushAsync(new exPage());*/

            button.Clicked += (sender, e) =>
            {
                var b = (Button)sender;
                var item = (ListItem)b.CommandParameter;
            };

In the comment there's how I'd do it with a single button.. But I've no idea how to do it with a list.. Someone can help me pls??

Answers

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    You have to create the list using a ViewCell. In the ViewCell you will have the button and the code you have posted

  • mwizard27mwizard27 ITMember ✭✭

    @AlessandroCaliaro parli italiano?

    I did it and I've already the button for each element of my list.. I'd like to know how I'd be able to set an event handler with which I can open a new page for each element

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    Yes, I feel you want write me a private message

    If your commented code is inside a ViewCell it should work. Which is the problem?

  • mwizard27mwizard27 ITMember ✭✭

    @AlessandroCaliaro said:
    Yes, I feel you want write me a private message

    If your commented code is inside a ViewCell it should work. Which is the problem?

    ti ho scritto in pm grazie :)

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    You can also connect with slack. There is an Italian chat ...

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    @mwizard27 said:

    @AlessandroCaliaro said:
    Yes, I feel you want write me a private message

    If your commented code is inside a ViewCell it should work. Which is the problem?

    ti ho scritto in pm grazie :)

    I don't see it... Can you retry?

Sign In or Register to comment.