maui
maui copied to clipboard
RadioButton with an inline content definition doesn't display it properly on Android
Description
Defined a RadioButton with an inline content definition.
Instead of displaying the Content, this shows the type name.
Refer to the screenshot for more details.
Steps to Reproduce
- Create a new .NET MAUI App
- Add a new Content Page and the below code snippet to simulate the issue
- Set this newly added page as the Main page
- Set Android as the target platform, build and then run the project
- And it works fine in Windows without any issue and unable to check on the other platforms
<?xml version="1.0" encoding="UTF-8" ?>
<ContentPage
x:Class="Issue6614.TestPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:m="clr-namespace:Microsoft.Maui;assembly=Microsoft.Maui"
Title="TestPage">
<ContentPage.Resources>
<ResourceDictionary>
<m:Thickness x:Key="OptionPadding">3,0,0,0</m:Thickness>
</ResourceDictionary>
</ContentPage.Resources>
<StackLayout
HorizontalOptions="Center"
RadioButtonGroup.GroupName="AppTheme"
VerticalOptions="Center">
<RadioButton IsChecked="{Binding UseSystem}" Value="system">
<RadioButton.Content>
<Label Padding="{StaticResource OptionPadding}" Text="Use System" />
</RadioButton.Content>
</RadioButton>
<RadioButton IsChecked="{Binding LightTheme}" Value="light">
<RadioButton.Content>
<Label Padding="{StaticResource OptionPadding}" Text="Light" />
</RadioButton.Content>
</RadioButton>
<RadioButton IsChecked="{Binding DarkTheme}" Value="dark">
<RadioButton.Content>
<Label Padding="{StaticResource OptionPadding}" Text="Dark" />
</RadioButton.Content>
</RadioButton>
</StackLayout>
</ContentPage>
Version with bug
Release Candidate 2 (current)
Last version that worked well
Release Candidate 1
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
Android 31.0
Did you find any workaround?
Have to set the value to the Content directly instead of using the extended Content definition.
Relevant log output
NA
Attached is the project to simulate the issue.
Windows Screenshot:
Android Screenshot:
I'm wondering if this is the cause: https://github.com/dotnet/maui/blob/main/src/Controls/src/Core/RadioButton.cs#L563
Do you see anything like that in the logging @egvijayanand?
Not adding the needs-info tag as it seems an obvious bug we can work on. Just trying to get more information without actually debugging it (yet)
@jfversluis Let me try again to check if anything is getting logged.
@jfversluis Here's the Debug log.
Hope it helps. Since I don't see any phrase that is mentioned in the link shared. Let me know if it's getting logged somewhere else.
Verified this issue with Visual Studio Enterprise 17.3.0 Preview 1.0 [32427.455.main]. Repro on Android with above Issue6614.zip project.
Any update on this? I'm also having this issue.
I'm wondering if this is the cause: https://github.com/dotnet/maui/blob/main/src/Controls/src/Core/RadioButton.cs#L563
Do you see anything like that in the logging @egvijayanand?
Not adding the needs-info tag as it seems an obvious bug we can work on. Just trying to get more information without actually debugging it (yet)
Right.
[DOTNET] [40m[1m[33mwarn[39m[22m[49m: Microsoft.Maui.Controls.RadioButton[0]
[DOTNET] Warning - Android does not support View as the Content property of RadioButton; the return value of the ToString() method will be displayed instead.
[DOTNET] [40m[1m[33mwarn[39m[22m[49m: Microsoft.Maui.Controls.RadioButton[0]
[DOTNET] Warning - Android does not support View as the Content property of RadioButton; the return value of the ToString() method will be displayed instead.
[DOTNET] [40m[1m[33mwarn[39m[22m[49m: Microsoft.Maui.Controls.RadioButton[0]
[DOTNET] Warning - Android does not support View as the Content property of RadioButton; the return value of the ToString() method will be displayed instead.
[DOTNET] OnCreated
Do you see anything like that in the logging @egvijayanand?
Will check and update.
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.
This is the expected behavior for a RadioButton on Android; the Android platform doesn't support arbitrary in-line content: https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/radiobutton?view=net-maui-7.0#display-arbitrary-content
To display arbitrary content on Android, you'll need to set a ControlTemplate for the RadioButton: https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/radiobutton?view=net-maui-7.0#redefine-radiobutton-appearance