I have the following XAML code:
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="False" x:Name="PageBar">
<shell:ApplicationBarIconButton IconUri="/Assets/Icons/appbar.questionmark.rest.png" Text="Help" x:Name="HelpIcon" Click="HelpIcon_Click" />
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="Help" x:Name="HelpItem" Click="HelpIcon_Click" />
<shell:ApplicationBarMenuItem Text="About" x:Name="AboutItem" Click="AboutItem_Click" />
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
But inside C# code is always null
.
Do you know why?
In some stupid decision an ApplicationBar isn't a standard Silverlight object, because of that it doesn't really fit in the visual tree, can't be bound to and x:Name doesn't work.
You can refer to the ApplicationBar via a property on the PhoneApplicationPage.
var helpItem = this.ApplicationBar.MenuItems[0];
var aboutItem = this.ApplicationBar.MenuItems[1];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With