Skip to content

[Android] Fix RadioButton using ContentPresenter not rendering#25947

Merged
PureWeen merged 6 commits intomainfrom
fix-25887
Nov 21, 2024
Merged

[Android] Fix RadioButton using ContentPresenter not rendering#25947
PureWeen merged 6 commits intomainfrom
fix-25887

Conversation

@jsuarezruiz
Copy link
Copy Markdown
Contributor

@jsuarezruiz jsuarezruiz commented Nov 19, 2024

Description of Change

Fix RadioButton using ContentPresenter not rendering on Android. Found the cause of the problem. The binding from ContentPresenter changed here 4c3a09c#diff-f01d408e1d2b3cd4a4c1bcf731586c215c9d57d4585d6815d5c89118a1ef3f44R20 (changes to allow trimming).

This PR apply changes to implement IContentView.Content in the RadioButton class.

Issues Fixed

Fixes #25887
The changes here, will also fix #24949

@jsuarezruiz jsuarezruiz added t/bug Something isn't working area-xaml XAML, CSS, Triggers, Behaviors platform/android area-controls-radiobutton RadioButton, RadioButtonGroup labels Nov 19, 2024
{
/// <include file="../../docs/Microsoft.Maui.Controls/RadioButton.xml" path="Type[@FullName='Microsoft.Maui.Controls.RadioButton']/Docs/*" />
public partial class RadioButton : TemplatedView, IElementConfiguration<RadioButton>, ITextElement, IFontElement, IBorderElement, IRadioButton
public partial class RadioButton : TemplatedView, IElementConfiguration<RadioButton>, IContentView, ITextElement, IFontElement, IBorderElement, IRadioButton
Copy link
Copy Markdown
Contributor Author

@jsuarezruiz jsuarezruiz Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To get the RadioButton working with the compiled binding in ContentPresenter, needs to implement IContentView.Content.

To get ContentPresenter correctly working in all the cases, we must apply the same changes to:

  • TitleBar
  • IndicatorView

Classes from Controls that inherit from TemplatedView.

Waiting for feedback to proceed and also include tests related to those classes, or just keep what is related to RadioButton here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative c6c2cee
Just revert the binding change in the ContentPresenter, but this change was necessary to make MAUI trimmable.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've modified the PR slightly

I think it's still relevant even with the alternative changes.

With Simons changes RB will still fall through to the unsafe path, so we need it to still react correctly and not go the unsafe path with warnings.

@PureWeen PureWeen marked this pull request as ready for review November 19, 2024 19:23
@PureWeen PureWeen requested a review from a team as a code owner November 19, 2024 19:23
mattleibow

This comment was marked as off-topic.

Copy link
Copy Markdown
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think @mattleibow is on to something here.

It does feel like this should work
#24949 (comment)

I tested locally real quick and it didn't work, but, there might just be something simple that needs to be added/fixed

@PureWeen PureWeen merged commit 59ce48d into main Nov 21, 2024
@PureWeen PureWeen deleted the fix-25887 branch November 21, 2024 17:21
@PureWeen
Copy link
Copy Markdown
Member

/backport to release/9.0.1xx

@github-actions
Copy link
Copy Markdown
Contributor

Started backporting to release/9.0.1xx: https://github.com/dotnet/maui/actions/runs/11958376858

@samhouts samhouts added the fixed-in-net8.0-nightly This may be available in a nightly release! label Dec 16, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-radiobutton RadioButton, RadioButtonGroup area-xaml XAML, CSS, Triggers, Behaviors fixed-in-9.0.21 fixed-in-net8.0-nightly This may be available in a nightly release! platform/android t/bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

TemplatedView and TemplateBinding not working anymore in NET9 ContentPresenter just rendering component string in .Net9

5 participants