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 ...
Get Windows® Phone 8 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.