From f126268ef630f9527e0f16d65c12acc39ff933a2 Mon Sep 17 00:00:00 2001
From: NirmalKumarYuvaraj
<97871636+NirmalKumarYuvaraj@users.noreply.github.com>
Date: Fri, 28 Feb 2025 21:04:28 +0530
Subject: [PATCH] Fixed FontImageSource icon color does not change in the
TabbedPage when dynamically updated. (#27742)
* Fixed The FontImageSource icon color does not change in the TabbedPage when dynamically updated.
* Updated code changes
---
src/Controls/src/Core/Page/Page.cs | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/Controls/src/Core/Page/Page.cs b/src/Controls/src/Core/Page/Page.cs
index 39ff6d2c2eaf..2c23d673d1d5 100644
--- a/src/Controls/src/Core/Page/Page.cs
+++ b/src/Controls/src/Core/Page/Page.cs
@@ -65,7 +65,7 @@ public partial class Page : VisualElement, ILayout, IPageController, IElementCon
public static readonly BindableProperty TitleProperty = BindableProperty.Create(nameof(Title), typeof(string), typeof(Page), null);
/// Bindable property for .
- public static readonly BindableProperty IconImageSourceProperty = BindableProperty.Create(nameof(IconImageSource), typeof(ImageSource), typeof(Page), default(ImageSource));
+ public static readonly BindableProperty IconImageSourceProperty = BindableProperty.Create(nameof(IconImageSource), typeof(ImageSource), typeof(Page), default(ImageSource), propertyChanged: OnImageSourceChanged);
readonly Lazy> _platformConfigurationRegistry;
@@ -902,6 +902,20 @@ internal void SendNavigatedFrom(NavigatedFromEventArgs args, bool disconnectHand
}
}
+ static void OnImageSourceChanged(BindableObject bindable, object oldvalue, object newValue)
+ {
+ if (oldvalue is ImageSource oldImageSource)
+ oldImageSource.SourceChanged -= ((Page)bindable).OnImageSourceSourceChanged;
+
+ if (newValue is ImageSource newImageSource)
+ newImageSource.SourceChanged += ((Page)bindable).OnImageSourceSourceChanged;
+ }
+
+ void OnImageSourceSourceChanged(object sender, EventArgs e)
+ {
+ OnPropertyChanged(IconImageSourceProperty.PropertyName);
+ }
+
///
/// Raised after the page was navigated to.
///