c# - Application crashes on changing Application Bar visibility -
i creating panorama application , want custumize application bar, visible single page. have created application bar in xaml:
<phone:phoneapplicationpage.applicationbar> <shell:applicationbar x:name="appbar_opere" isvisible="false" ismenuenabled="true" mode="default" opacity="0.95" > <shell:applicationbariconbutton iconuri="/assets/appbar/feature.search.png" text="cauta" /> <shell:applicationbariconbutton iconuri="/assets/appbar1/favs.png" text="favorite" /> <shell:applicationbariconbutton iconuri="/assets/appbar2/feature.settings.png" text="setari" /> <shell:applicationbar.menuitems> <shell:applicationbarmenuitem text="clasa ix-a" /> <shell:applicationbarmenuitem text="clasa x-ea" /> <shell:applicationbarmenuitem text="clasa xi-ea" /> <shell:applicationbarmenuitem text="clasa xii-ea" /> </shell:applicationbar.menuitems> </shell:applicationbar> </phone:phoneapplicationpage.applicationbar>
then, using selectionchanged event, writen code:
private void panorama_selectionchanged(object sender, selectionchangedeventargs e) { switch(((panorama)sender).selectedindex) { case 1: appbar_opere.isvisible = true; break; default: appbar_opere.isvisible = false; break; } }
ok. when navigate page want applicationbar visible, app crashes, "object reference not set instance of object" on line:
appbar_opere.isvisible = true;
why?
applicationbar not silverlight control, can't access way. correctly code is:
private void panorama_selectionchanged(object sender, selectionchangedeventargs e) { switch(((panorama)sender).selectedindex) { case 1: applicationbar.isvisible = true; break; default: applicationbar.isvisible = false; break; } }
Comments
Post a Comment