Changing ApplicationBar Icons for Theme Awareness

If you have light and dark sets of your icon,you can make it work by writing these codes on your Loaded event of PhoneApplication Page:

 private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            var visibility = (Visibility)Application.Current.Resources["PhoneLightThemeVisibility"];
            if (visibility == Visibility.Visible)
            {
                 
                var button = (IApplicationBarIconButton)ApplicationBar.Buttons[1];
                button.IconUri=new Uri("H_light.png",UriKind.Relative);
            }
 
            else
            {
                var button = (IApplicationBarIconButton)ApplicationBar.Buttons[1];
                button.IconUri = new Uri("H_dark.png", UriKind.Relative);
            }
        }

So after building and running the project,it'll be working like a charm.

Hope it helps! 


Ebook Download
View all
Learn
View all
Araf Global is a software consultancy company founded in 2016 focusing on cutting edge technologies.