Skip to content

Commit

Permalink
Fixed FontImageSource icon color does not change in the TabbedPage wh…
Browse files Browse the repository at this point in the history
…en dynamically updated. (dotnet#27742)

* Fixed The FontImageSource icon color does not change in the TabbedPage when dynamically updated.

* Updated code changes
  • Loading branch information
NirmalKumarYuvaraj authored Feb 28, 2025
1 parent 196a1d6 commit f126268
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Controls/src/Core/Page/Page.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/// <summary>Bindable property for <see cref="IconImageSource"/>.</summary>
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<Page>> _platformConfigurationRegistry;

Expand Down Expand Up @@ -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);
}

/// <summary>
/// Raised after the page was navigated to.
/// </summary>
Expand Down

0 comments on commit f126268

Please sign in to comment.