Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

#8293 - uwp - imagebutton - Font Icon Disappears when Minimizing Wind… #13971

Closed
wants to merge 1 commit into from

Conversation

MichielDG
Copy link

Description of Change

Uwp seems to replace images with transparent images inside a button image when resuming the app after suspending it.
To fix this issue we set the ImageSource again when the app is resuming.
Refreshing the ImageSource is not enough.
To accomplish this the ButtonImageRenderer has to subscribe to the Resuming eventhandler.

Issues Resolved

API Changes

Added:

  • async void OnResumingAsync(object sender, object e) in the Xamarin.Forms.Platform.UWP.ButtonImageRenderer which subscribed to Windows.UI.Xaml.Application.Current.Resuming
    Changed:
  • none

Removed:

  • none

Platforms Affected

  • UWP

Behavioral/Visual Changes

  • icon Images in an imagebutton are not transparent after suspending and then resuming the app again

Before/After Screenshots

  • not fixed
    • before suspend
      image
    • after suspend
      image
  • fixed
    • before suspend
      image
    • after suspend
      image

Testing Procedure

  1. Create a new Xamarin Forms app with an UWP project
  2. Add a fonticon (fa-regular-400.ttf) as Embedded resource into the shared project
  3. Add in the assemblyInfo.cs this line:
[assembly: ExportFont("fa-regular-400.ttf", Alias = "far")] 
  1. Add an image button to the MainPage with an icon inside:
<ImageButton HeightRequest="50" Margin="6" WidthRequest="50" BackgroundColor="Transparent" 
                           HorizontalOptions="FillAndExpand" VerticalOptions="Center">
  <ImageButton.Source>
    <FontImageSource Glyph="&#xf06e;" FontFamily="far" Size="44" Color="White"/>
  </ImageButton.Source>
</ImageButton>
  1. Start the app
  2. When the app is loaded suspend the app.
  3. Resume the app
  4. Image/icon should be visible and should not be transparent

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)

…ng Window in UWP

When the uwp app suspends and resumes again the image source should be reupdated as uwp replaces images with transparent images onResume
@Alex-Witkowski
Copy link

Does the same change/fix taht was applied for ImageRenderer in #8783.
Looks good 👍

@djrpascu
Copy link

Thanks for this PR! 👍

@djrpascu
Copy link

djrpascu commented May 7, 2021

@samhouts would it be possible to get this PR merged into an upcoming release? much mahalo!

@hellyeahniels
Copy link

This bug is also still present on Button FontImages.

@jfversluis
Copy link
Member

Now that we're so close to the sunsetting of Xamarin.Forms unfortunately we won't be able to take this in anymore, we're really sorry about that. Nevertheless, thank you so much for your time and effort that you have put into this PR.

Please have a look at the evolution of Xamarin.Forms, .NET MAUI. A lot of development has been going on there. Hopefully this issue was already fixed in that codebase. If not, feel free to port this over to there.

Again, thank you so much for being a contributor and Xamarin.Forms user!

@jfversluis jfversluis closed this Apr 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Font Icon Disappears when Minimizing Window in UWP
6 participants