Reputation: 2947
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!
Upvotes: 4
Views: 2041
Reputation: 3818
you can right click on the project then > Add > Existing Item , Then add your .png image that meets the criteria that mr Jon Skeet mentioned in the above answer.
after that you should find the the image appear in the solution explorer , right click on the image from the solution explorer > Properties then change the 'Build Action' property to 'Content'
hope this works
peace
Upvotes: 0
Reputation: 4576
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.
Upvotes: 13
Reputation: 1499770
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 :)
Upvotes: 2