Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,14 @@ void ApplyTintColor(FrameworkElement platformView, View element, Color? color)

void LoadAndApplyImageTintColor(View element, WImage image, Color color)
{
if (element is IImageElement { Source: UriImageSource uriImageSource })
// Sometimes WImage source doesn't match View source so the image is not ready to be tinted, have to wait for next ImageOpened event
if (element is IImageElement { Source: FileImageSource fileImageSource } &&
image.Source is BitmapImage bitmapImage &&
Uri.Compare(new Uri($"{bitmapImage.UriSource.Scheme}:///{fileImageSource.File}"), bitmapImage.UriSource, UriComponents.Path, UriFormat.Unescaped, StringComparison.OrdinalIgnoreCase) != 0)
{
image.ImageOpened += OnImageOpened;
}
else if (element is IImageElement { Source: UriImageSource uriImageSource })
{
image.Source = Path.GetExtension(uriImageSource.Uri.AbsolutePath) switch
{
Expand All @@ -140,6 +147,10 @@ void LoadAndApplyImageTintColor(View element, WImage image, Color color)

ApplyTintColor();
}
else if (image.IsLoaded)
{
ApplyTintColor();
}
else
{
image.ImageOpened += OnImageOpened;
Expand Down