hi,listview grouping help me ..
my function ;
`
public async Task getVoyagesData()
{
voyagesList.Clear();
try
{
var uri = new Uri(url);
HttpClient myClient = new HttpClient();
var response = await myClient.GetAsync(uri);
var content = await response.Content.ReadAsStringAsync();
JObject results = JObject.Parse(content);
var results2 = results["data"];
if (response.IsSuccessStatusCode)
{
foreach (var i in results2)
{
VoyagesMdl voyDay = new VoyagesMdl();
VoyagesMdl voyNight = new VoyagesMdl();
string clock;
clock = i["time"].Value<string>().Substring(11);
int clockker = Convert.ToInt32(clock.Substring(0, 2));
if (!(clockker > 18 || clockker < 6))
{
voyDay.opactiy = "1";
voyDay.rectangle_price = "rectangle.png";
voyDay.rectangle2_date = "rectangle2.png";
voyDay.resim = "day.png";
voyDay.textcolor = "Black";
if (i["prop_ekran"].Value<bool>())
voyDay.prop_ekran_img = "ekrantv_day.png";
else
voyDay.prop_ekran_img = "null";
if (i["prop_ekranmuzik"].Value<bool>())
voyDay.prop_ekran_img = "ekranmuzik_day.png";
else
voyDay.prop_ekran_img = "null";
if (i["prop_k21"].Value<bool>())
voyDay.koltuktipi = "2+2";
else
voyDay.koltuktipi = "2+1";
voyDay.clock = clock;
voyDay.id = i["id"].Value<int>();
voyDay.name = i["name"].Value<string>();
voyDay.time = i["time"].Value<string>();
voyDay.time_description = i["time_description"].Value<string>();
voyDay.extra = i["extra"].Value<bool>();
voyDay.vehicle_type = i["vehicle_type"].Value<string>();
voyDay.list_price = i["list_price"].Value<decimal>();
voyDay.price = i["price"].Value<decimal>() + " ₺";
voyDay.prop_ekran10 = i["prop_ekran10"].Value<bool>();
voyDay.prop_ekrantv = i["prop_ekrantv"].Value<bool>();
voyDay.prop_ekranmuzik = i["prop_ekranmuzik"].Value<bool>();
voyDay.prop_ekranfm = i["prop_ekranfm"].Value<bool>();
voyDay.prop_geneltv = i["prop_geneltv"].Value<bool>();
voyDay.prop_cep = i["prop_cep"].Value<bool>();
voyDay.prop_usbsarj = i["prop_usbsarj"].Value<bool>();
voyDay.prop_v220 = i["prop_v220"].Value<bool>();
voyDay.prop_internet = i["prop_internet"].Value<bool>();
voyDay.prop_futbol = i["prop_futbol"].Value<bool>();
voyDay.prop_wc = i["prop_wc"].Value<bool>();
voyDay.prop_kulaklik = i["prop_kulaklik"].Value<bool>();
voyDay.prop_express = i["prop_express"].Value<bool>();
voyagesListDay.Add(voyDay);
}
else
{
voyNight.opactiy = "1";
voyNight.rectangle_price = "rectangle_night.png";
voyNight.rectangle2_date = "rectangle2_night.png";
voyNight.resim = "night.png";
voyNight.textcolor = "White";
if (i["prop_ekran"].Value<bool>())
voyNight.prop_ekran_img = "ekrantv.png";
else
voyNight.prop_ekran_img = "null";
if (i["prop_ekranmuzik"].Value<bool>())
voyNight.prop_ekran_img = "ekranmuzik.png";
else
voyNight.prop_ekran_img = "null";
if (i["prop_k21"].Value<bool>())
voyNight.koltuktipi = "2+2";
else
voyNight.koltuktipi = "2+1";
voyNight.clock = clock;
voyNight.id = i["id"].Value<int>();
voyNight.name = i["name"].Value<string>();
voyNight.time = i["time"].Value<string>();
voyNight.time_description = i["time_description"].Value<string>();
voyNight.extra = i["extra"].Value<bool>();
voyNight.vehicle_type = i["vehicle_type"].Value<string>();
voyNight.list_price = i["list_price"].Value<decimal>();
voyNight.price = i["price"].Value<decimal>() + " ₺";
voyNight.prop_ekran10 = i["prop_ekran10"].Value<bool>();
voyNight.prop_ekrantv = i["prop_ekrantv"].Value<bool>();
voyNight.prop_ekranmuzik = i["prop_ekranmuzik"].Value<bool>();
voyNight.prop_ekranfm = i["prop_ekranfm"].Value<bool>();
voyNight.prop_geneltv = i["prop_geneltv"].Value<bool>();
voyNight.prop_cep = i["prop_cep"].Value<bool>();
voyNight.prop_usbsarj = i["prop_usbsarj"].Value<bool>();
voyNight.prop_v220 = i["prop_v220"].Value<bool>();
voyNight.prop_internet = i["prop_internet"].Value<bool>();
voyNight.prop_futbol = i["prop_futbol"].Value<bool>();
voyNight.prop_wc = i["prop_wc"].Value<bool>();
voyNight.prop_kulaklik = i["prop_kulaklik"].Value<bool>();
voyNight.prop_express = i["prop_express"].Value<bool>();
voyagesListNight.Add(voyNight);
}
}
var list = new List<VoyagesListGroup>()
{
voyagesListDay,
voyagesListNight,
};
voyagesListDay.Heading = "test";
voyagesListNight.Heading = "test";
ListOfGroupVoyages = list;
voyagesListview.ItemsSource = null;
voyagesListview.ItemsSource = ListOfGroupVoyages;
animationView.IsPlaying = false;
animationView.Pause();
animationView.Loop = false;
animationView.IsEnabled = false;
animationView.IsVisible = false;
}
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
}
my xaml listview :
<ListView x:Name="voyagesListview" IsGroupingEnabled="True"
HasUnevenRows="True" Grid.Row="4" >
<ListView.GroupHeaderTemplate>
<DataTemplate>
<ViewCell>
</ViewCell>
</DataTemplate>
</ListView.GroupHeaderTemplate>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid RowSpacing="0" Opacity="1">
<Grid.RowDefinitions>
<RowDefinition Height="35"/>
<RowDefinition Height="35"/>
<RowDefinition Height="35"/>
<RowDefinition Height="1"/>
</Grid.RowDefinitions>
<Image Source="{Binding resim}"
x:Name="daySource"
Grid.RowSpan="3" Aspect="AspectFill">
</Image>
<Grid Grid.Row="0" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="70"/>
</Grid.ColumnDefinitions>
<Image Source="path_black.png" Grid.Column="0" Margin="10"/>
<Label
Text="{Binding koltuktipi}"
TextColor="{Binding textcolor}"
Grid.Column="1"
VerticalTextAlignment="Center" HorizontalTextAlignment="Start"
FontSize="13">
<Label.FontFamily>
<OnPlatform x:TypeArguments="x:String">
<On Platform="Android" Value="openlight.ttf#openlight" />
<On Platform="iOS" Value="openlight.ttf#openlight" />
</OnPlatform>
</Label.FontFamily>
</Label>
<Image x:Name="img_path" Source="path_white.png" Grid.Column="0" Margin="10"/>
<Label
Text="{Binding vehicle_type}"
TextColor="{Binding textcolor}"
Grid.Column="2"
VerticalOptions="Center" HorizontalOptions="Center"
HorizontalTextAlignment="Center"
VerticalTextAlignment="Center">
<Label.FontFamily>
<OnPlatform x:TypeArguments="x:String">
<On Platform="Android" Value="open.ttf#open" />
<On Platform="iOS" Value="open.ttf#open" />
</OnPlatform>
</Label.FontFamily>
</Label>
<Image Source="{Binding rectangle_price}" Grid.Column="3" Aspect="Fill"/>
<Label
Text="{Binding price}"
TextColor="White"
Grid.Column="3"
VerticalOptions="Center" HorizontalOptions="Center"
HorizontalTextAlignment="Center"
VerticalTextAlignment="Center">
<Label.FontFamily>
<OnPlatform x:TypeArguments="x:String">
<On Platform="Android" Value="constantia.ttf#constantia" />
<On Platform="iOS" Value="constantia.ttf#constantia" />
</OnPlatform>
</Label.FontFamily>
</Label>
</Grid>
<Grid Grid.Row="1" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label
VerticalOptions="Center"
HorizontalOptions="Center"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
Text="{Binding name}"
Grid.Column="0"
TextColor="{Binding textcolor}">
<Label.FontFamily>
<OnPlatform x:TypeArguments="x:String">
<On Platform="Android" Value="openbold.ttf#openbold" />
<On Platform="iOS" Value="openbold.ttf#openbold" />
</OnPlatform>
</Label.FontFamily>
</Label>
</Grid>
<Grid Grid.Row="2" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="70"/>
</Grid.ColumnDefinitions>
<Image Source="{Binding rectangle2_date}" Grid.Column="0" Aspect="Fill" />
<Label
x:Name="otobus_saat"
Text="{Binding clock}"
TextColor="White"
FontSize="20"
Grid.Column="0"
VerticalTextAlignment="Center" HorizontalTextAlignment="Center">
<Label.FontFamily>
<OnPlatform x:TypeArguments="x:String">
<On Platform="Android" Value="constantia.ttf#constantia" />
<On Platform="iOS" Value="constantia.ttf#constantia" />
</OnPlatform>
</Label.FontFamily>
</Label>
<Grid Grid.Column="1" Grid.ColumnSpan="2" VerticalOptions="Center" HorizontalOptions="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Source="{Binding prop_ekran_img}" Grid.Column="0" />
<Image Source="{Binding prop_ekranmuzik_img}" Grid.Column="1" />
</Grid>
<Grid Grid.Column="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Source="detay.png" Grid.Column="0" />
<Label Text="Detaylı Bilgi"
TextColor="{Binding textcolor}"
Grid.Column="1" FontSize="9" VerticalTextAlignment="Center" HorizontalTextAlignment="Start"/>
</Grid>
</Grid>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
`
VoyagesListGroup class ;
public class VoyagesListGroup : List<VoyagesMdl> { public string Heading { get; set; } public List<VoyagesMdl> ListOfGroupVoyages => this; }
my VoyagesMdl class ;
` public class VoyagesMdl
{
public string opactiy { get; set; }
public string resim { get; set; }
public string textcolor { get; set; }
public string otobus_tipi { get; set; } //otobus_tipi
public string rectangle_price { get; set; } // paranın olduğu yerin background resmi // gece ,, gündüze göre değişyior
public string rectangle2_date { get; set; } //background
public string clock { get; set; }
public string koltuktipi { get; set; }
// küçük logolar
public string prop_ekran_img { get; set; }
public string prop_ekranmuzik_img { get; set; }
public int id { get; set; }
public string name { get; set; }
public string time { get; set; }
public string time_description { get; set; }
public bool extra { get; set; }
public string vehicle_type { get; set; }
public decimal list_price { get; set; }
public string price { get; set; }
public bool prop_k21 { get; set; }
public bool prop_ekran { get; set; }
public bool prop_ekran10 { get; set; }
public bool prop_ekrantv { get; set; }
public bool prop_ekranmuzik { get; set; }
public bool prop_ekranfm { get; set; }
public bool prop_geneltv { get; set; }
public bool prop_cep { get; set; }
public bool prop_usbsarj { get; set; }
public bool prop_v220 { get; set; }
public bool prop_internet { get; set; }
public bool prop_futbol { get; set; }
public bool prop_wc { get; set; }
public bool prop_kulaklik { get; set; }
public bool prop_express { get; set; }
}`