Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Set TabbedPage icons at runtime?

$
0
0

I'm trying to implement an interface to let my user know when certain data has been flagged. The cleanest way to do this is by changing the icons in my TabbedPage - which I'm having some trouble doing.

I hoped that maybe switching the "Icon" property on my Forms Page would change it in the tab bar but no dice. Here's my snippet - if anyone could look it over and maybe help figure out what else I need to do that'd be great :)

//This is in the TabbedPage
//Pages is a Dictionary<string, NavigationPage>
//Children maps to pages
public void FlagNotifications(bool hasNotifications)
{

    if (hasNotifications)
    {
        Device.BeginInvokeOnMainThread(() =>
        {
           pages["Notifications"].Icon = (FileImageSource)ImageSource.FromFile("icon_notifications_accent.png");
        });
    }
    else {
        Device.BeginInvokeOnMainThread(() => 
        {
           pages["Notifications"].Icon = (FileImageSource)ImageSource.FromFile("icon_notifications.png");
        });
    }

}

Viewing all articles
Browse latest Browse all 91519

Trending Articles