Skip to content

Commit f126268

Browse files
Fixed FontImageSource icon color does not change in the TabbedPage when dynamically updated. (dotnet#27742)
* Fixed The FontImageSource icon color does not change in the TabbedPage when dynamically updated. * Updated code changes
1 parent 196a1d6 commit f126268

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Controls/src/Core/Page/Page.cs

+15-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public partial class Page : VisualElement, ILayout, IPageController, IElementCon
6565
public static readonly BindableProperty TitleProperty = BindableProperty.Create(nameof(Title), typeof(string), typeof(Page), null);
6666

6767
/// <summary>Bindable property for <see cref="IconImageSource"/>.</summary>
68-
public static readonly BindableProperty IconImageSourceProperty = BindableProperty.Create(nameof(IconImageSource), typeof(ImageSource), typeof(Page), default(ImageSource));
68+
public static readonly BindableProperty IconImageSourceProperty = BindableProperty.Create(nameof(IconImageSource), typeof(ImageSource), typeof(Page), default(ImageSource), propertyChanged: OnImageSourceChanged);
6969

7070
readonly Lazy<PlatformConfigurationRegistry<Page>> _platformConfigurationRegistry;
7171

@@ -902,6 +902,20 @@ internal void SendNavigatedFrom(NavigatedFromEventArgs args, bool disconnectHand
902902
}
903903
}
904904

905+
static void OnImageSourceChanged(BindableObject bindable, object oldvalue, object newValue)
906+
{
907+
if (oldvalue is ImageSource oldImageSource)
908+
oldImageSource.SourceChanged -= ((Page)bindable).OnImageSourceSourceChanged;
909+
910+
if (newValue is ImageSource newImageSource)
911+
newImageSource.SourceChanged += ((Page)bindable).OnImageSourceSourceChanged;
912+
}
913+
914+
void OnImageSourceSourceChanged(object sender, EventArgs e)
915+
{
916+
OnPropertyChanged(IconImageSourceProperty.PropertyName);
917+
}
918+
905919
/// <summary>
906920
/// Raised after the page was navigated to.
907921
/// </summary>

0 commit comments

Comments
 (0)