maui icon indicating copy to clipboard operation
maui copied to clipboard

RadioButton with an inline content definition doesn't display it properly on Android

Open egvijayanand opened this issue 3 years ago • 6 comments

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

  1. Create a new .NET MAUI App
  2. Add a new Content Page and the below code snippet to simulate the issue
  3. Set this newly added page as the Main page
  4. Set Android as the target platform, build and then run the project
  5. 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

egvijayanand avatar Apr 28 '22 13:04 egvijayanand

Attached is the project to simulate the issue.

Issue6614.zip

Windows Screenshot:

dotnetmaui-issue6614-windows-output

Android Screenshot:

dotnetmaui-issue6614-android-screenshot

egvijayanand avatar Apr 28 '22 14:04 egvijayanand

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 avatar Apr 28 '22 14:04 jfversluis

@jfversluis Let me try again to check if anything is getting logged.

egvijayanand avatar Apr 28 '22 14:04 egvijayanand

@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.

Debug-Log.txt

egvijayanand avatar Apr 28 '22 15:04 egvijayanand

Verified this issue with Visual Studio Enterprise 17.3.0 Preview 1.0 [32427.455.main]. Repro on Android with above Issue6614.zip project.

XamlTest avatar Apr 29 '22 01:04 XamlTest

Any update on this? I'm also having this issue.

Core121 avatar Aug 09 '22 19:08 Core121

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

jsuarezruiz avatar Aug 24 '22 12:08 jsuarezruiz

Do you see anything like that in the logging @egvijayanand?

Will check and update.

egvijayanand avatar Aug 24 '22 12:08 egvijayanand

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.

ghost avatar Aug 31 '22 15:08 ghost

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

hartez avatar Feb 01 '23 18:02 hartez