简体   繁体   中英

Application Bar items in windows phone 7

in my windows phone app, i have an application bar menu item named item_1 and radiobutton button_1 , i have put the IsEnabled property of the item_1 as false; and so when i check the button_1 the IsEnabled property of item_1 should be made true; for that i have written the following code in c#

 public void button_1_checked(object sender,RoutedEventArgs e)
 {
    this.item_1.IsEnabled=true;
    -----rest of the code----
 }

but this is giving a NullReferenceException , what should i do to make the item_1 enabled?

This is because the ApplicationBar does not get properly bound via the Name property. You need to access it via code:

var button1 = (ApplicationBarIconButton) ApplicationBar.Buttons[0];
button1.IsEnabled = true;

This link might be helpful for you: How to: Create an Application Bar in Code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM