Maui icon indicating copy to clipboard operation
Maui copied to clipboard

[BUG] Windows IconTintColorBehavior Navigate away and then back to a page and the tint is removed

Open SamuelJames101 opened this issue 1 year ago • 7 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

  • [X] I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug

Current Behavior

Navigating away from a page which has an image and a tint, and then back to removes a the tint

Expected Behavior

The tint remains

Steps To Reproduce

1.Have a page with an image with a tint 2.Navigate to a second page 3.Navigate back to the first page

https://github.com/CommunityToolkit/Maui/assets/44027336/5d5634fa-cb14-4e05-bc3a-1e4bf0c2bd51

Link to public reproduction project repository

https://github.com/SamuelJames101/IconTintColourWindowsIssue

Environment

- .NET MAUI CommunityToolkit: 7.0.0
- OS: Windows 11 22H2
- .NET MAUI: Net8 GA

Anything else?

No response

SamuelJames101 avatar Dec 08 '23 16:12 SamuelJames101

Thanks @SamuelJames101 for reporting the issue. I have verified the issue.

vhugogarcia avatar Dec 08 '23 20:12 vhugogarcia

@vhugogarcia I have created a fix in my code but I have a question, why do we remove the tint when we un-attach the behaviour? As that is where the issue lies, if we don't remove the tint but instead make sure the view (the image with the attached behaviour) only has one IconTintBehaviour at any given time then that resolved it for me.

SamuelJames101 avatar Jan 23 '24 11:01 SamuelJames101

@SamuelJames101 can you attach your workaround? @vhugogarcia is this scheduled any time soon for a fix?

gsgou avatar Feb 13 '24 09:02 gsgou

Also having this issue, ETA on a fix?

@SamuelJames101 Would also like to see your workaround if possible.

RuddyOne avatar Apr 02 '24 15:04 RuddyOne

I think it he fix for this is to apply a similar approach to how StatusBarBehavior works - allowing a developer to define when the behavior is applied and make the default do it in OnNavigatedTo.

I'm away for just over a week but happy to look at this when I return if there isn't any progress.

bijington avatar Apr 02 '24 17:04 bijington

I am also running into this issue on windows. The first time the view is displayed it works fine, but navigating back to the view results in no tint. Hopefully a fix is coming in the near future.

The work around that I am using requires re-setting of the image's source in the view's Loaded event.

private IconTintColorBehavior myIconTint = new();

private void MyView_Loaded(object sender, EventArgs e)
{
     if (myImage.Behaviors.Contains(myIconTint))
     {
         var source = myImage.Source;
         myImage.Source = null;
         myImage.Source = source;
     }
     else
     {
         myImage.Behaviors.Add(myIconTint);
     }
}

sbloom82 avatar Apr 29 '24 15:04 sbloom82

Any progress on this? Or a way to overwrite all images to fix this for now?

RuddyOne avatar Aug 09 '24 08:08 RuddyOne