siema robię liste produktów i mam problem na głownej stronie mam listy ktore zawierają produkty po kliknięciu powinny się wyswietlac produkty zawarte w danej liscie a po kliknięciu jedynie przezyca mnie na strone ale nic sie nie wyswiatla
funkcja ta jest w code behind glownej strony
private void TapGestureRecognizer_Tapped(object sender, EventArgs e)
{
var senderBindingContext = ((StackLayout)sender).BindingContext;
var lists = (Lists)senderBindingContext;
Navigation.PushAsync(new DetailsPage(lists));
}
tutaj jest xaml
<StackLayout>
<ListView
x:Name="ProductListView"
HasUnevenRows="True"
IsGroupingEnabled="True"
GroupDisplayBinding="{Binding Title}"
SeparatorColor="White"
>
<ListView.GroupHeaderTemplate>
<DataTemplate>
<ViewCell>
<StackLayout
Orientation="Horizontal"
HorizontalOptions="Fill"
HeightRequest="100"
BackgroundColor="LightGray"
Margin="10,10,10,0"
>
<StackLayout.GestureRecognizers>
<TapGestureRecognizer
Tapped="TapGestureRecognizer_Tapped" glownie to chcialem pokazac
NumberOfTapsRequired="1"/>
</StackLayout.GestureRecognizers>
<Label
Text="{Binding Title}"
HorizontalOptions="StartAndExpand"
FontSize="20"
Margin="15,35,0,0"
TextColor="Gray"/>
<Button
Text="Podgląd"
Clicked="Button_Clicked_1"
CommandParameter="{Binding .}"
Margin="0,0,10,0"
FontSize="20"
TextColor="Gray"
BackgroundColor="LightGray"
/>
</StackLayout>
<ViewCell.ContextActions>
<MenuItem
Text="Usuń"
CommandParameter="{Binding .}"
IsDestructive="True"
Clicked="MenuItem_Clicked_1"/>
</ViewCell.ContextActions>
</ViewCell>
</DataTemplate>
</ListView.GroupHeaderTemplate>
</ListView>
strona na ktorą nas przekierowywuje
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Lista.Classes;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
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;
//ListListView.BindingContext = Lists;
InitializeComponent();
}
}
}
i xaml
<?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"
>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Label
Text="{Binding Name}"
FontSize="16"
VerticalOptions="Center"
WidthRequest="100"
TextColor="Gray"
Margin="10,0,0,0"
/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>
jeszcze klasa Lists jakby ktos chcial
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;
namespace Lista.Classes
{
public class Lists : ObservableCollection<Product>
{
public string Title { get; set; }
public List<Product> ProductList { get; set; }
private bool isShow;
public Lists(string title, List<Product> productList)
{
this.Title = title;
ProductList = productList;
isShow = true;
}
public void preview()
{
if (isShow)
{
foreach (var product in ProductList)
{
base.Add(product);
}
}
else
{
base.Clear();
}
isShow = !isShow;
}
}
}