i’m developing a Windows Phone 7.1 Application,
this is the ApplicationBar :
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True"
IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="/add.png"
Text="Add"
x:Name="addItem"
Click="addItem_Click" />
<shell:ApplicationBarIconButton IconUri="/edit.png"
Text="Edit"
x:Name="edit"
IsEnabled="False"
Click="edit_Click" />
<shell:ApplicationBarIconButton IconUri="/remove.png"
Text="Remove"
x:Name="remove"
IsEnabled="False"
Click="remove_Click" />
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="Clear"
x:Name="clr"
Click="clr_Click" />
<shell:ApplicationBarMenuItem Text="Logout"
Click="ApplicationBarMenuItem_Click"
x:Name="logout" />
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
when i refer to its elements, named ‘edit’ and ‘remove’ :
edit.IsEnabled = true;
remove.IsEnabled = true;
it gets nullreference exception.
any solutions?
you have to retreive the object in code behind :