Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Phone 7 doesn't show Icons inside ApplicationBar Buttons

I'm developing my first Windows Phone 7 application and I have to add an Application Bar with icons.

I referred to this "How To" : http://msdn.microsoft.com/en-us/library/ff431786(VS.92).aspx ("Creating an Application Bar in XAML" paragraph)

But when I run Emulator I cannot see incons: I see the black circle with X in the center and event ApplicationBarIconButton_Click correctly raised.

I'm using icon from WP7AppBarIcons.zip samples and my code is posted below:

<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="/images/appbar.transport.play.rest.png" Text="Home" Click="ApplicationBarIconButton_Click"/>
<shell:ApplicationBarIconButton IconUri="/images/appbar.favs.rest.png" Text="Preferiti" Click="ApplicationBarIconButton_Click"/>
<shell:ApplicationBarIconButton IconUri="/images/appbar.questionmark.rest.png" Text="About" Click="ApplicationBarIconButton_Click"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

Obviously, I have a root solution folder named "images" containing the mentioned 48 x 48 icons.

Thanks a lot!

like image 793
Nicola C. Avatar asked Dec 07 '22 00:12

Nicola C.


2 Answers

Are the images Build Action set to "Content" rather than "Resource" as this is a common mistake - I've done it a couple of times myself. They need to be this way as ApplicationBar is not a Silverlight control and the images need to be set to Content.

like image 69
RoguePlanetoid Avatar answered Dec 22 '22 00:12

RoguePlanetoid


Are your PNGs definitely 2 colour, just white on a transparent background? IIRC they won't load if that's not the case. You might want to grab a PNG from a sample project which does work, just to check whether it's the file contents that are causing the problem or something else.

Also, check the case of "images" - all the samples use "Images" instead of "images"; probably not what's wrong, but worth checking :)

like image 40
Jon Skeet Avatar answered Dec 22 '22 00:12

Jon Skeet