maui icon indicating copy to clipboard operation
maui copied to clipboard

.NET MAUI 8 FontImageSource image update under Android not rendered after page reloaded and after Display mode switched between Light and Dark.

Open vsfeedback opened this issue 10 months ago • 1 comments

This issue has been moved from a ticket on Developer Community.


[severity:It bothers me. A fix would be nice] ImageButton FontImageSource graphic assigned in code-behind, the one labeled Up on the below screenshot,

Screenshot_1708528570.png

disappears after navigating to another flyout page and then navigating back to the first page. Only images changed in code-behind are affected.

Screenshot_1708529079.png

Next screenshot shows the page after the Light mode selected while the app running, and that page was in view.

Screenshot_1708529788.png

Four bottom bar buttons and the navigation bar arrow button are visible and correctly rendered according to the selected theme. The next screenshot shows what the page looks like after navigating to the next page, then coming back to the first page.

Screenshot_1708530183.png

All font images disappeared, including images never changed in code-behind. The second page that was not visible during switching to Light mode is not affected. It shows correct font graphics after navigated to. A workaround is to add code in Page.Appearing(). For each font graphic save the Glyph to a string variable. Set the .Glyph to an empty string or NULL. Set the .Glyph back to the saved value.

That solves both issues, kind of. iOS is not affected. The below screenshots are from a test I initially created to investigate an unrelated issue with CollectionView. The project can be looked up at https://github.com/mikebikerider/CollectionViewSample-net8.git


Original Comments

Feedback Bot on 2/21/2024, 10:47 PM:

(private comment, text removed)


Original Solutions

(no solutions)

vsfeedback avatar Apr 02 '24 18:04 vsfeedback

I found another odd workaround for this. For affected Image buttons Issue a Clicked EventHandler in PageAppearing(), with the EventArgs set to NULL. Make sure the EventHandler code checks EventsArgs for NULL and does nothing if it is. That also solves another ugly FontImageSource issue - the button can be rendered as disabled when it is enabled. and clickable. A physical click works as expected and also restores the correct image. That gave me the idea. I regret tagging this issue as 'It bothers me'. If not for the workaround I can barely live with, I would have to ditch FontImageSource for Android projects. That would be another nail into the coffin of the MAUI Single Project Codebase ambition.

mikebikerider avatar Apr 02 '24 19:04 mikebikerider