Forum Xamarin Cross Platform with Xamarin

Passing data from list to new view xamarin

Ive created a picker with data inside, when selected the data is added to a list. I want to the values that are added to the list to follow to the next page when calculate button is pressed.. tried a few different approaches but i cant get it right..


// add from picker to listview function

    ObservableCollection<LayersClass> listProducts = new ObservableCollection<LayersClass>();

    private void MainPicker_SelectedIndexChanged(object sender, EventArgs e)
        // feedback popup box
         var product = MainPicker.Items[MainPicker.SelectedIndex];
         DisplayAlert(product, "Layer added to calculation list", "OK");
        // if selected add to list          
        if (null != product)
            LayersClass layer = new LayersClass();
            layer.Product = product;

    //calculate button
    private async void Button_Clicked(object sender, EventArgs e)

        // send selected values to CalculationPage ??
        await Navigation.PushAsync(new CalculationPage());

Xaml Code:

                        <MenuItem Clicked="MenuItem_Clicked" Text="Delete" IsDestructive="true" CommandParameter="{Binding .}" />
                        <Label Text="{Binding Product}"></Label>
    <Button Margin="0,0,0,90" Text="Calculate" Clicked="Button_Clicked"  FontSize="Medium" TextColor="#00AB8E"  HorizontalOptions="Center"      BackgroundColor="Transparent"/>

Best Answer


Sign In or Register to comment.