Skip to content

Commit 12fa1ae

Browse files
Update IconTintColorBehavior.windows.cs
1 parent 868faab commit 12fa1ae

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/IconTintColor/IconTintColorBehavior.windows.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected override void OnDetachedFrom(View bindable, FrameworkElement platformV
3838

3939
bindable.PropertyChanged -= OnElementPropertyChanged;
4040
PropertyChanged -= OnIconTintColorBehaviorPropertyChanged;
41-
41+
4242
RemoveTintColor(platformView);
4343
}
4444

@@ -77,7 +77,7 @@ void OnIconTintColorBehaviorPropertyChanged(object? sender, PropertyChangedEvent
7777
ArgumentNullException.ThrowIfNull(sender);
7878
var iconTintColorBehavior = (IconTintColorBehavior)sender;
7979

80-
if(iconTintColorBehavior.View is not IView bindable
80+
if (iconTintColorBehavior.View is not IView bindable
8181
|| bindable.Handler?.PlatformView is not FrameworkElement platformView)
8282
{
8383
return;
@@ -99,7 +99,7 @@ void OnIconTintColorBehaviorPropertyChanged(object? sender, PropertyChangedEvent
9999
void OnElementPropertyChanged(object? sender, PropertyChangedEventArgs e)
100100
{
101101
if (e.PropertyName is not string propertyName
102-
|| sender is not View bindable
102+
|| sender is not IView bindable
103103
|| bindable.Handler?.PlatformView is not FrameworkElement platformView)
104104
{
105105
return;
@@ -155,10 +155,11 @@ void LoadAndApplyImageTintColor(IView element, WImage image, Color color)
155155
}
156156
else if (image.IsLoaded)
157157
{
158-
// Sometimes WImage source doesn't match View source so the image is not ready to be tinted, have to wait for next ImageOpened event
159-
if (element is IImageElement { Source: FileImageSource fileImageSource } &&
160-
image.Source is BitmapImage bitmapImage &&
161-
Uri.Compare(new Uri($"{bitmapImage.UriSource.Scheme}:///{fileImageSource.File}"), bitmapImage.UriSource, UriComponents.Path, UriFormat.Unescaped, StringComparison.OrdinalIgnoreCase) != 0)
158+
// Sometimes WImage source doesn't match View source so the image is not ready to be tinted
159+
// We must wait for next ImageOpened event
160+
if (element is IImageElement { Source: FileImageSource fileImageSource }
161+
&& image.Source is BitmapImage bitmapImage
162+
&& Uri.Compare(new Uri($"{bitmapImage.UriSource.Scheme}:///{fileImageSource.File}"), bitmapImage.UriSource, UriComponents.Path, UriFormat.Unescaped, StringComparison.OrdinalIgnoreCase) is not 0)
162163
{
163164
image.ImageOpened += OnImageOpened;
164165
}

0 commit comments

Comments
 (0)