0
votes

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?

1

1 Answers

1
votes

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