Application bar in windows phone 7 -


i trying create application bar in windows phone 7 application. think there problem click event because works , not work.

below code in xaml , .cs .

xaml

    <shell:applicationbar isvisible="true" ismenuenabled="false">         <shell:applicationbariconbutton iconuri="/icons/appbar.edit.rest.png" text="edit" click="btnedit_click" isenabled="true"/>         <shell:applicationbariconbutton iconuri="/icons/appbar.delete.rest.png" text="delete" click="btndelete_click" isenabled="true"/>         <shell:applicationbariconbutton iconuri="/icons/appbar.feature.email.rest.png" text="email"  click="btnemail_click" isenabled="true"/>         <shell:applicationbariconbutton iconuri="/icons/appbar.back.rest.png" text="back" click="btnback_click" isenabled="true"/>      </shell:applicationbar> </phone:phoneapplicationpage.applicationbar> 

.cs

 void btnback_click(object sender, eventargs e)      {         navigationservice.navigate(new uri("/library.xaml", urikind.relative));     }      void btndelete_click(object sender, eventargs e)     {         messagebox.show("can click");     } 

can me it. thanks.

one possible situation can think of library page has heavy constructor navigating page takes long. situation can make illusion tap on button 2 3 times , think not working while first 1 has been triggered thread still thinking building next page.

try simple messagebox instead of navigation see if guess true.

if is, try make page constructor light possible , data loading "asynchronus" , in "onnavigatedto".

for data load: reading list of items load on library page. loading items requires reading them file system, web service or other media time-consuming , can block ui. need in onnavigatedto (to make sure starts after user navigated page) , asynchronously this:

public override void onnavigatedto(...) {     system.threading.threadpool.queueuserworkitem(loaddata); }  void loaddata(object o) {     res = // load data media.     deployment.current.dispatcher.begininvoke(() =>      {         // add res page     }); } 

anything write directly in code behind of page run on ui thread (except animations handled separate thread). need keep tasks not related ui in separate thread (in way shown above).

note still need trigger ui changes in ui thread otherwise "corss-thread exception". (thats why invoking code in dispatcher.begininvoke).


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -