I think you have to use grouped listview https://learn.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/userinterface-listview-grouping/
or you have to modify your "Model" so you have one line for each date
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
In my xaml file, I have a this ListView :
<ListView x:Name="MyListView" ItemsSource="{Binding MyData}" HasUnevenRows="true">
<ListView.ItemTemplate>
<DataTemplate x:Name="dataTemplate">
<ViewCell>
<FramePadding="2" BorderColor="DarkSlateGray">
<Grid x:Name="grid" Padding="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.6*"/>
<ColumnDefinition Width="2.5*"/>
<ColumnDefinition Width="2.5*"/>
<ColumnDefinition Width="2.5*"/>
<ColumnDefinition Width="2.5*"/>
<ColumnDefinition Width="2.5*"/>
<ColumnDefinition Width="2.5*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" VerticalTextAlignment="Center" >
<Label.FormattedText>
<FormattedString>
<Span TextDecorations="Underline" TextColor="Black" Text="{Binding dateName}"/>
<Span Text="{x:Static system:Environment.NewLine}"/>
<Span Text="{Binding date}"/>
</FormattedString>
</Label.FormattedText>
</Label>
<Label Grid.Column="{Binding gridNumber}" Grid.ColumnSpan="2" HorizontalTextAlignment="Center" BackgroundColor="{Binding BgColor}">
<Label.FormattedText>
<FormattedString>
<Span TextColor="Black" Text="{Binding Information}"/>
</FormattedString>
</Label.FormattedText>
</Label>
<BoxView BackgroundColor="DarkSlateGray" WidthRequest="3" Grid.Column="0" HorizontalOptions="EndAndExpand" VerticalOptions="FillAndExpand" />
<BoxView IsVisible="{Binding IsSimpleSeance}" BackgroundColor="DarkSlateGray" WidthRequest="1" Grid.Column="{Binding gridNumber}" HorizontalOptions="EndAndExpand" VerticalOptions="FillAndExpand"/>
<BoxView BackgroundColor="DarkSlateGray" WidthRequest="1" Grid.Column="2" HorizontalOptions="EndAndExpand" VerticalOptions="FillAndExpand"/>
<BoxView BackgroundColor="DarkSlateGray" WidthRequest="1" Grid.Column="3" HorizontalOptions="EndAndExpand" />
<BoxView BackgroundColor="DarkSlateGray" WidthRequest="1" Grid.Column="5" HorizontalOptions="EndAndExpand" VerticalOptions="FillAndExpand"/>
<BoxView BackgroundColor="DarkSlateGray" WidthRequest="1" Grid.Column="6" HorizontalOptions="EndAndExpand" VerticalOptions="FillAndExpand"/>
</Grid>
</Frame>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
And in my ViewModel file, I had this ObservableCollection<MyObject>:
lObservableCollectionist<MyObject> MyList = [
{"Monday", "07/12", "Some Data in First Line", 1},
{ "Monday", "07/12", "Some Other Data ALSO in First Line",4},
{ "Tuesday", "08/12", "New Data in Second Line" ,1},
{ "Tuesday", "08/12", "New Other Data in Second Line",4 },
{ "Tuesday", "08/12", "Newest Data Also in Second Line",6 },
...
]
So, the problem is the ListView display each element of the ObservableCollection in new line like this
But what I want is to group the same day data in one line. Something like this
So , Any Help !
I think you have to use grouped listview https://learn.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/userinterface-listview-grouping/
or you have to modify your "Model" so you have one line for each date