Open acaliaro opened 1 year ago
a collectionview inside a stacklayout
Why are you putting a CollectionView inside of a StackLayout?
a collectionview inside a stacklayout
Why are you putting a CollectionView inside of a StackLayout?
I don't understand the question. Is forbidden?
https://github.com/dotnet/maui/issues/8888#issuecomment-1192527270 I read this.. Really? Is this the motivation? So do I have to be careful what layout I use to hold a collectionview?
I can't see your repository code but If you have a grid with row Auto the 'Explicit concurrent copying GC freed' seems to kick in in full force. If you have any Auto rows try setting them to another value to alleviate it.
#8888 (comment) I read this.. Really? Is this the motivation? So do I have to be careful what layout I use to hold a collectionview?
Well, you need to use an appropriate layout for whatever it is that you're trying to achieve. If you want the CollectionView to fit into a limited vertical space and be scrollable, then a vertically-oriented stacking layout is probably not what you're looking for.
Also, I'm asking because I can't see your code; the repro project you linked to seems to be empty. Are you wrapping the CollectionView in a StackLayout to provide some other layout feature (like a margin, or padding, or background)? Does the StackLayout have other controls in it?
I can't see your repository code but If you have a grid with row Auto the 'Explicit concurrent copying GC freed' seems to kick in in full force. If you have any Auto rows try setting them to another value to alleviate it.
Sorry, now you should see the repo
#8888 (comment) I read this.. Really? Is this the motivation? So do I have to be careful what layout I use to hold a collectionview?
Well, you need to use an appropriate layout for whatever it is that you're trying to achieve. If you want the CollectionView to fit into a limited vertical space and be scrollable, then a vertically-oriented stacking layout is probably not what you're looking for.
Also, I'm asking because I can't see your code; the repro project you linked to seems to be empty. Are you wrapping the CollectionView in a StackLayout to provide some other layout feature (like a margin, or padding, or background)? Does the StackLayout have other controls in it?
I wrap the CV inside a StackLayout because I would like to add more controls before the collectionview. In the repo I added a verticalStackLayout in row 1 column 2 position with some labels before the collectionview: same result, scroll doesn't work.
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Honestly this is a major issue. I am trying to set all the HeightRequests, but this doesn't make sense. I am using the same "Component" over and over again, inside this component, there is a grid, a label and a collectionview. within that collectionview I am using a DataTemplateSelector
to decide which of the datatemplates to load and based on their "type" (small, medium, large) I am using different Widths... the need to set Heights defies the purpose of VerticalOptions
FillAndExpand
.
Those "Components" are in a VStackLayout inside a StackLayout because there are multiple "Components" and over Controls on the Page.
So is there a fix for this planned, is there a workaround? Can I help with the implementation of a fix? Right now I have no clue where this is even coming form :/
The issues I've experienced, such as this, are what led me to step away from Xamarin and consider other solutions. It can be incredibly frustrating when fundamental aspects don't work properly, I hope MAUI will not continue the same path. Anyway here is a temporary solution.
<ContentPage>
<Grid
x:Name="ParentGrid"
SizeChanged="ParentGrid_SizeChanged">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<CollectionView
x:Name="MessagesCollectionView"
ItemTemplate="{StaticResource MessageTemplateSelector}"
Grid.Row="0">
</CollectionView>
<Grid
x:Name="NewMessageGrid"
Grid.Row="1">
</Grid>
</Grid>
</ContentPage>
public partial class ChatPage : ContentPage
{
void ParentGrid_SizeChanged(System.Object sender, System.EventArgs e)
{
MessagesCollectionView.HeightRequest = ParentGrid.Height - (MessageGrid.Height + ParentGrid.Margin.Top + ParentGrid.Margin.Bottom);
}
}
Verified this on Visual Studio Enterprise 17.7.0 Preview 2.0. Repro on Android 13.0-API33 with below Project: MauiAppGridProblem.zip
Not sure if this is related. If not, let me know and I'll create a new issue.
.NET MAUI 7.0:
Inside of a CollectionView
using a <Grid ColumnDefinitions="*, Auto">
with only the first column implemented, the unused Auto
causes the row to not show the text. Only after resizing the window (on desktop) does the screen resize the row and show the text, otherwise this will always appear as a blank row. Once you remove the unused column definition of Auto
the CollectionView shows the row just fine.
BTW, this bug helped uncover our developer defining an unused column definition. Sooo.. win/win?
<CollectionView ItemsSource="{Binding Devices}"
SelectedItem="{Binding DeviceSelected, Mode=TwoWay}"
SelectionMode="Single">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="models:DeviceListItem">
<SwipeView>
<SwipeView.RightItems>
<!-- (code removed for bug clarity) -->
</SwipeView.RightItems>
<!--
BUG:
When using AUTO and the 2nd column is not provided, the screen doesn't render
the text until the window is resized (Windows desktop), otherwise, it stays blank (i.e. Android)
-->
<Grid ColumnDefinitions="*,Auto">
<Label Text="{Binding DisplayName}"
FontSize="Large"
TextColor="AliceBlue" />
</Grid>
</SwipeView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
the row to not show the text. Only after resizing the window (on desktop) does the screen resize the row and show the text,
Ive found this or very similar behavior of text missing from the selected item of a Picker
, which was inside of a CollectionView
, where resizing the WinUI
Window
immediately resolves the issue.
After minor adjustments for Margin/Padding, and swapping an encapsulating Frame
for Border
, the problem stopped happening.
In other words there appears to me a problem with text appearance in controls within a CollectionView
, but to me it doesn't appear related to this bug at all.
Also seeing issues similar to this on Android.
If you have a Collectionview inside of a Grid with rows setup as "Auto,*" (Stacklayout row 0, Collectionview row 1). Then the collection view when populated seems to randomly start from the bottom cell. You have to scroll back up to get to the top. Weird.
Any movement on this issue?
Description
Hello. I need to use collectionviews within a grid. It seems that collectionviews when inside a grid don't work very well. For example, in the attached project I have this situation: in a 2*3 grid I have: 1- row 0 column 0, a collectionview inside a stacklayout. Instead of staying in the first cell, the collectionview occupies all the cells of the same column, and scrolling doesn't work 2- row 0 column 1, a collectionview with a griditemslayout, scrolling but slowly 3- row 1 column 1, a collectionview with a griditemslayout, inside a stacklayout: don't scroll 4- row 0 column 2, a collectionview that scrolls, but slowly
during scrolling, I see a lot of
[iappgridproble] Explicit concurrent copying GC freed 9457(570KB) AllocSpace objects, 0(0B) LOS objects, 70% free, 5112KB/16MB, paused 79us total 34.070ms [iappgridproble] Explicit concurrent copying GC freed 312(39KB) AllocSpace objects, 0(0B) LOS objects, 70% free, 5137KB/17MB, paused 40us total 27.919ms [iappgridproble] Explicit concurrent copying GC freed 306(39KB) AllocSpace objects, 0(0B) LOS objects, 70% free, 5161KB/17MB, paused 40us total 27.764ms
Steps to Reproduce
There is a project linked
Link to public reproduction project repository
https://github.com/acaliaro/MauiAppGridProblem
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 10
Did you find any workaround?
No
Relevant log output