O'Reilly logo

Windows® Phone 8 Unleashed by Daniel Vaughan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Retrieving a Button or Menu Item at Runtime

Although the built-in application bar allows you to assign names to buttons and menu items in XAML using the x:Name attribute, the CLR runs into trouble resolving items by name at runtime. Consider the following example:

<phoneNavigation:PhoneApplicationPage.ApplicationBar>    <shell:ApplicationBar>        <shell:ApplicationBar.Buttons>            <shell:ApplicationBarIconButton                IconUri="/Images/Play.png"                Click="OnPlayButtonClick" />            <shell:ApplicationBarIconButton                x:Name="PauseButton"                IconUri="/Images/Pause.png"                Click="OnPlayButtonClick"                IsEnabled="True" />        </shell ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required