siema mam problem jak wejde w liste to chciałbym aby wyswietlało mi produkty ktore sie w niej znajdują na innej stronie a przerzuca mnie tylko na pustą strone, jak to zrobic?
kod
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using Lista.Classes;
using System.Collections.ObjectModel;
namespace Lista.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class FirstPage : ContentPage
{
public ObservableCollection<Lists> productList { get; set; }
public FirstPage()
{
InitializeComponent();
productList = new ObservableCollection<Lists>
{
new Lists("w lidlu", new List<Product>
{
new Product { Name = "ogórki"},
new Product { Name = "poprotka"},
new Product { Name = "woda"},
}),
new Lists("elektryczny", new List<Product>
{
new Product { Name = "kabel hdmi"},
new Product { Name = "adapter bluetooth"},
new Product { Name = "baterie"},
})
};
ProductListView.ItemsSource = productList;
}
private void Button_Clicked(object sender, EventArgs e)
{
}
private void MenuItem_Clicked(object sender, EventArgs e)
{
var menuitem = sender as MenuItem;
var product = menuitem.CommandParameter as Product;
foreach (var lists in productList)
{
if (lists.Contains(product))
{
lists.Remove(product);
}
}
}
private void Button_Clicked_1(object sender, EventArgs e)
{
var button = sender as Button;
var lists = button.CommandParameter as Lists;
lists.preview();
}
private void Button_Clicked_2(object sender, EventArgs e)
{
ShowDialogAsync();
}
private void MenuItem_Clicked_1(object sender, EventArgs e)
{
//var menuitem = sender as MenuItem;
//var listt = menuitem.CommandParameter as Lists;
//listt.Remove(listt);
}
private void createlist(string listname)
{
var productList = new List<Product>
{
//new Product()
//{
// Name = "Jabłka"
//},
//new Product()
//{
// Name = "Jogurt"
//}
};
var lists = new Lists(listname.ToString(), productList);
this.productList.Add(lists);
}
private async void ShowDialogAsync()
{
string result = await App.Current.MainPage.DisplayPromptAsync("Tworzenie listy", "Podaj nazwe listy:");
if (result != null)
{
createlist(result);
}
else
{
}
}
private void TapGestureRecognizer_Tapped_1(object sender, EventArgs e)
{
var senderBindingContext = ((StackLayout)sender).BindingContext;
var lists = (Lists)senderBindingContext;
Navigation.PushAsync(new DetailsPage(lists));
}
private void Button_Clicked_3(object sender, EventArgs e)
{
Navigation.PushAsync(new OtherPage());
}
private void Button_Clicked_4(object sender, EventArgs e)
{
Navigation.PushAsync(new SettingsPage());
}
}
}
na tej stronie maja sie wyswietlac produkty
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Lista.Views.DetailsPage">
<StackLayout>
<ListView
x:Name="ListListView"
HasUnevenRows="True"
SeparatorColor="White"
BindingContext="">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout
>
<Label
Text="{Binding Name}"
/>
<!--zrobic buttona albo itemselected co zmienia swoj text z odznacz na fajke-->
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>
a tu code behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using Lista.Classes;
namespace Lista.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class DetailsPage : ContentPage
{
public Lists Lists { get; set; }
public DetailsPage(Lists lists)
{
Lists = lists;
this.BindingContext = Lists;
InitializeComponent();
}
}
}
funkcja TapGestureRecognizer_Tapped_1 ma mnie przezucac na tą strone z produktami danej listy