Problem:
I ran into this error trying to disable a icon on the Application Bar of my Windows Phone Application. I declared the applicationbar declaratively and not programmatically. When I went to
access the applicationbar icon I assigned it a name property using x:Name. The control resolved to
null.
AppBarEmailButton.IsEnabled = true;
Error Message:
System.NullReference: Object Reference not set to an instance of an object.
Solution:
Microsoft.Phone.Shell.ApplicationBarIconButton btn = (ApplicationBarIconButton )ApplicationBar.Buttons[0];
btn.IsEnabled = true;
or declare the applicationbar programmatically.
Source
http://blogs.msdn.com/b/ptorr/archive/2010/06/18/why-are-the-applicationbar-objects-not-frameworkelements.aspx?wa=wsignin1.0
http://stackoverflow.com/questions/5334574/applicationbariconbutton-is-null
http://social.technet.microsoft.com/wiki/contents/articles/975.updating-applicationbariconbutton-dynamically.aspx
No comments:
Post a Comment