Changing ApplicationBar Icons for Theme Awareness

By Ibrahim Ersoy Jun 25, 2012
Its quite a punch in the face for WP7 developers,but i'll give you a hand here.
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);
                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! 

Ibrahim Ersoy

Ibrahim Ersoy lives in Turkey, Istanbul. He helps running and managing C# Corner. He is a Software Consultant (Sharepoint) and MindCracker MVP. He writes about cutting-edge Microsoft Technologies including XNA,... Read more

Personal Blog:


Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

Latest Blogs