Closed BinaryAssault closed 7 months ago
verified repro except the first scenario with vs 17.2.0 Preview 3.0 [32314.195.main]
@shimingsg, can you double check the xaml for the radio buttons? Curious why the background color is to the right of the group. Maybe you accidentally discovered a workaround? Also in the same scenario, does clicking the SwitchCell cause the issue to occur?
Lastly, why does your keyboard not show when clicking an entry?
@BinaryAssault , I used the xaml in "Steps to Reproduce", please see the attached demo MauiApp5292.zip the scenario I did: click option 2 -> option3 -> option 1 -> entry
It seems our emulators are of different APIs. I am using A10 and you're using A11. But even using A11, if I select one of the pickers or the SwitchCell, the radio button view cell disappears.
Example below is from A11
Related. ViewCell not only disappears when unfocused, it also fails to appear at all in some "advanced" cases. I'll reuse the code I used in this issue few weeks back. Just replace the xaml with this:
<ContentPage.Resources>
<conv:InverseBoolConverter x:Key="inverseBool"/>
</ContentPage.Resources>
<ScrollView>
<VerticalStackLayout>
<TableView Intent="Settings" BackgroundColor="AliceBlue">
<TableRoot>
<TableSection>
<ViewCell>
<Grid ColumnDefinitions="*, *" >
<Label Text="Use all sources:" />
<CheckBox Grid.Column="1" IsChecked="{Binding UseAllNames}" x:Name="AllNamesCheckBox" />
</Grid>
</ViewCell>
</TableSection>
</TableRoot>
</TableView>
<ListView ItemsSource="{Binding Names}">
<ListView.ItemTemplate>
<DataTemplate>
<SwitchCell On="{Binding Selected}" Text="{Binding Value}" IsEnabled="{Binding On, Source={x:Reference AllNamesSwitchCell}, Converter={StaticResource inverseBool}}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<TableView Intent="Settings" BackgroundColor="AliceBlue">
<TableRoot>
<TableSection>
<ViewCell>
<Grid ColumnDefinitions="*, *" >
<Label Text="Use all surnames:" />
<CheckBox Grid.Column="1" IsChecked="{Binding UseAllSurnames}" x:Name="AllSurnamesSwitchCell" />
</Grid>
</ViewCell>
</TableSection>
</TableRoot>
</TableView>
<ListView ItemsSource="{Binding Surnames}">
<ListView.ItemTemplate>
<DataTemplate>
<SwitchCell On="{Binding Selected}" Text="{Binding Value}" IsEnabled="{Binding On, Source={x:Reference AllSurnamesSwitchCell}, Converter={StaticResource inverseBool}}" >
</SwitchCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</VerticalStackLayout>
</ScrollView>
And you will see, that the ViewCell does not appear at all
If I play around with TableSelection at runtime (Hot Reload), I can make them appear (don't mind the ugly UI)
This may be an async timing issue. When I was running the emulator without a hypervisor the controls in the ViewCell would briefly show up. Sometimes it would disappear, sometimes it wouldn't, it was erratic.
When I enabled the hypervisor the emulator was much more performant and I didn't have problems with the ViewCell disappearing shortly after being drawn. It could be coincidence but it would explain why this always can't be reproduced.
It only seems to be an issue with the ViewCells. The SwitchCells don't disappear (nor the EntryCells I tested).
https://user-images.githubusercontent.com/4380198/171073026-42fc082b-3214-4ee5-b768-84b94de0b067.mp4
Edit to add: And now it's back. Here is my XAML.
<Grid ColumnDefinitions="150, *" RowDefinitions="50, 200, *">
<Label Grid.Row="0" Grid.ColumnSpan="2" Text="Cat Question" FontSize="20" VerticalTextAlignment="Center" Margin="10, 0, 0, 0" />
<AbsoluteLayout Grid.Row="1" Grid.Column="0">
<Image Source="images/trouble_cat.jpg" Aspect="AspectFill" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0, 0, 1, 1" />
<Label Text="Trouble Cat" HorizontalTextAlignment="Center" FontSize="20" AbsoluteLayout.LayoutFlags="PositionProportional,WidthProportional" AbsoluteLayout.LayoutBounds="0, 1, 1, 25" />
</AbsoluteLayout>
<Label Grid.Row="1" Grid.Column="1" Margin="10, 0, 0, 0" VerticalTextAlignment="Center" Text="How cute do you think this cat is?" />
<TableView Grid.Row="2" Grid.ColumnSpan="2" RowHeight="50">
<TableRoot>
<TableSection>
<SwitchCell Text="Meh, I've seen cuter" />
<SwitchCell Text="That doesn't look like a dog" />
<ViewCell>
<Grid ColumnDefinitions="*, 50" RowDefinitions="50">
<Label Grid.Row="0" Grid.Column="0" VerticalTextAlignment="Center" Text="SuperCute!" />
<RadioButton Grid.Row="0" Grid.Column="1" IsChecked="True" GroupName="Answer" BackgroundColor="Transparent" />
</Grid>
</ViewCell>
<ViewCell>
<Grid ColumnDefinitions="*, 50" RowDefinitions="50">
<Label Grid.Row="0" Grid.Column="0" VerticalTextAlignment="Center" Text="I can't believe how cute this cat is" />
<RadioButton Grid.Row="0" Grid.Column="1" GroupName="Answer" BackgroundColor="Transparent" />
</Grid>
</ViewCell>
</TableSection>
</TableRoot>
</TableView>
</Grid>
This may be an async timing issue. When I was running the emulator without a hypervisor the controls in the ViewCell would briefly show up. Sometimes it would disappear, sometimes it wouldn't, it was erratic.
When I enabled the hypervisor the emulator was much more performant and I didn't have problems with the ViewCell disappearing shortly after being drawn. It could be coincidence but it would explain why this always can't be reproduced.
It only seems to be an issue with the ViewCells. The SwitchCells don't disappear (nor the EntryCells I tested).
ViewCell.mp4 Edit to add: And now it's back. Here is my XAML.
<Grid ColumnDefinitions="150, *" RowDefinitions="50, 200, *"> <Label Grid.Row="0" Grid.ColumnSpan="2" Text="Cat Question" FontSize="20" VerticalTextAlignment="Center" Margin="10, 0, 0, 0" /> <AbsoluteLayout Grid.Row="1" Grid.Column="0"> <Image Source="images/trouble_cat.jpg" Aspect="AspectFill" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0, 0, 1, 1" /> <Label Text="Trouble Cat" HorizontalTextAlignment="Center" FontSize="20" AbsoluteLayout.LayoutFlags="PositionProportional,WidthProportional" AbsoluteLayout.LayoutBounds="0, 1, 1, 25" /> </AbsoluteLayout> <Label Grid.Row="1" Grid.Column="1" Margin="10, 0, 0, 0" VerticalTextAlignment="Center" Text="How cute do you think this cat is?" /> <TableView Grid.Row="2" Grid.ColumnSpan="2" RowHeight="50"> <TableRoot> <TableSection> <SwitchCell Text="Meh, I've seen cuter" /> <SwitchCell Text="That doesn't look like a dog" /> <ViewCell> <Grid ColumnDefinitions="*, 50" RowDefinitions="50"> <Label Grid.Row="0" Grid.Column="0" VerticalTextAlignment="Center" Text="SuperCute!" /> <RadioButton Grid.Row="0" Grid.Column="1" IsChecked="True" GroupName="Answer" BackgroundColor="Transparent" /> </Grid> </ViewCell> <ViewCell> <Grid ColumnDefinitions="*, 50" RowDefinitions="50"> <Label Grid.Row="0" Grid.Column="0" VerticalTextAlignment="Center" Text="I can't believe how cute this cat is" /> <RadioButton Grid.Row="0" Grid.Column="1" GroupName="Answer" BackgroundColor="Transparent" /> </Grid> </ViewCell> </TableSection> </TableRoot> </TableView> </Grid>
I'll have to disagree with you as this is still a failure on a physical android device for me. I tried on 3 different API levels and all did the same thing. Its a bummer that this is still a problem with GA as it really inhibits the ability to make a simple settings page. I have to either create a custom control to handle all my settings or breakout a slew custom XAML per setting to get the look of a table.
All I want is the ability to use a picker in settings, which requires a ViewCell; but I can't do that.
Please can this be fixed? It is a showstopper for MAUI migration - I cannot use ViewCells on Android (which work fine in Xamarin) and as @BinaryAssault comments there is no alternative to render many controls such as picker within a table, or to, for example render a grid within a table. @Redth why is this no longer a P1? I have the impression that GA for MAUI was premature with many breaking issues unresolved and an unrealistic timetable for Xamarin support ending when migration to MAUI is not feasible.
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.
It is really poor this is not being fixed. ViewCell does not work in maui and is a showstopper for migration. Please prioritise fixing critical maui bugs that stop migration over new features.
Being able to use ViewCells is important when using TableViews for Settings Pages.
I Was able to solve using
<TableView HeightRequest="700">
or any other large number.
I'm not sure how it will work on larger screens.
Maybe the problem has something to do with the TableView or ViewCell Height property
I Was able to solve using
<TableView HeightRequest="700">
or any other large number. I'm not sure how it will work on larger screens. Maybe the problem has something to do with the TableView or ViewCell Height property
Interesting, the HeightRequest indeed does work to fight the issue. But that shouldn't be required.
On the same line, I tried setting VerticalOptions and MinimumHeightRequest and neither of those worked. I also tried a height on the ViewCell itself without any luck.
Setting the HeightRequest
for the entire control is not a solution, because in most scenarios, you don't know what the Height needs to be. This issue should be worked on rather soon, otherwise TableView
is not a useful control. I would strongly disagree with using this "workaround" as an excuse to not fix this bug.
I Was able to solve using
<TableView HeightRequest="700">
or any other large number. I'm not sure how it will work on larger screens. Maybe the problem has something to do with the TableView or ViewCell Height property
Thank you, this unblocked my MAUI migration.
Any Update on the final solution?
Same issue here with disappearing controls and other layout bugs when using a tableview with custom viewcells.
@Redth @hartez @davidortinau We run into similar issues with the tableview and custom viewcells. We are in a process of migrating a Xamarin.Forms project to MAUI and any page that uses a tableview has issues as the one described here with disappearing controls.
Here is a very simple reproducible case https://github.com/YiannisBourkelis/maui_issues/tree/main/src/TableViewDisappearingControlsIssue Run it on Android/iOS/MacCatalyst and you will se that the label does not appear. Changing the label control to an Entry and you will discover more issues.
Tableviews are very essential part of any mobile app and should work as expected. Please let me know if I can provide more examples of the issues we are experiencing with the tableview so that you can easily identify these issues.
The workaround, e.g.
HeightRequest="{OnPlatform Android=700}"
...does not resolve the issue, depending on the screen content, the layout affects can be very strange, including exposing the underlying screen when a modal dialogue is displayed with a TableView.
@davidortinau please can this be prioritised, as you can see from the above it is a blocker for Xamarin -> maui migration for many.
Much appreciated.
This is really a showstopper. Any update on this?
This is in no way a solution for this, but I ran across this repo here which provides a fully functional settings view. This will allow a functional settings page. It is in preview, so use at your own risk. It's more functional than the native MAUI TableView
I have success with the HasUnevenRows="True"
on the TableView, see the dokumentation Size Items:
<TableView Intent="Settings" HasUnevenRows="True">
<TableRoot>
<TableSection Title="Silent">
<ViewCell>
<Grid ColumnDefinitions="0.5*,0.5*" RowDefinitions="Auto,Auto">
<Label Margin="10,10,0,0" Text="Vibrate" />
<Switch Grid.Column="1" HorizontalOptions="End" />
<Slider
Grid.Row="1"
Grid.ColumnSpan="2"
Margin="10"
Maximum="10"
Minimum="0"
Value="3" />
</Grid>
</ViewCell>
</TableSection>
</TableRoot>
</TableView>
Verified on Visual Studio Enterprise 17.6.0 Preview 3.0. This issue repro except the first scenario on Android emulator (13.0-API 33) with below Project: 5292.zip
This seems related to
It seems to be affecting many users as it is a basic usecase.
@davidortinau @jfversluis @Redth can you please put a priority on this again to fix this? It was prioritized as p1
before by @davidortinau and then dropped again...
Also some feedback - the transparency to customers is really low here - it was triaged/verified more than a year ago
then it was prioritized
and then put on the backburner without an explanation or suggested workaround.
What I am really missing is transparent communication on these points:
For customers, having to make a guess based on tags that can seemingly be added or removed arbitrarily is difficult, and it does not instill confidence in how Maui bugs are treated.
@hansmbakker appreciate the feedback, but I don't think this is the place for it. This will only steer this issue potentially off-topic which will not really help getting this resolved any sooner.
Confirming bug still exists on VS2022 LTSC 17.4.11 with maui-android 7.0.92/7.0.100 and android 33.0.68/7.0.100 workloads installed.
If it's any help, I've been developing using an actual device, a Samsung Galaxy A52 running Android 13 with September security updates. Issue persists on other android devices used for testing as well.
Still not working on .NET 8, with Visual Studio Preview 17.8.0 Preview 2.0
Aswell not working on .net 7 VS 17.7.5
Hi everyone ! I think i found an interesting workaround for this problem ! I took the OnMeasure from the PlatformRenderer : https://github.com/dotnet/maui/blob/8e933a7a7a46fdb586918e7414345d978cb0878d/src/Compatibility/Core/src/Android/PlatformRenderer.cs#L79
This is the workaround i found :
public class MyTableViewHandler : TableViewRenderer
{
public MyTableViewHandler(Context context) : base(context)
{
}
//Do not call base.OnMeasure(widthMeasureSpec, heightMeasureSpec); !!!
protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
int width = MeasureSpec.GetSize(widthMeasureSpec);
int height = MeasureSpec.GetSize(heightMeasureSpec);
SetMeasuredDimension(width, height);
for (int i = 0; i < ChildCount; i++)
{
Android.Views.View child = GetChildAt(i);
child.Measure(MeasureSpec.MakeMeasureSpec(width, MeasureSpecMode.Exactly),
MeasureSpec.MakeMeasureSpec(height, MeasureSpecMode.Exactly));
}
}
}
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
//...
.ConfigureMauiHandlers((handlers) =>
{
#if ANDROID
handlers.AddHandler(typeof(TableView), typeof(MyTableViewHandler));
#endif
});
//...
return builder.Build();
}
}
MAUI .NET 7, VS 17.8.2, ViewCell content blanked out (Android only) with the following actions,
Application.Current.UserAppTheme = AppTheme.xxx
Both of the above are resolved by using workaround https://github.com/dotnet/maui/issues/5292#issuecomment-1804531480.
@Bennynation thank you for the workaround! I've been going crazy with the TableView
. I 100% use custom layouts as my view cells and as soon as they update their layout, everything just disappears. There are so many issues reported for this same thing.
@Cybrosys That's why I stopped using it in favor of StackLayouts with custom components.
@Cybrosys That's why I stopped using it in favor of StackLayouts with custom components.
I was doing something similar, but I went back to TableView
as I wanted the default touch/tap effects.
This should be fixed on SR2 by https://github.com/dotnet/maui/pull/20130
Description
It seems that when you use a ViewCell in any TableView, it will disappear. The disappear seems to occur when something new focuses.
A few examples:
Steps to Reproduce
Version with bug
Preview 13 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
Android 10
Did you find any workaround?
No
Relevant log output