c# - How to call an event from other page Windows Phone? -


i making upload app windows phone, function in class b (secondpage), have upload task, when task completed, call event , notice class (mainpage) task done , things, looking around site, found solutions don't (just think that).

  1. notify when event class triggered

  2. raise event of class different class in c#

  3. understanding events , event handlers in c#

  4. c# event handling (compared java)

  5. c#: need 1 of classes trigger event in class update text box

here code in secondpage

public sealed partial class secondpage : page {     public event eventhandler clearhandler = delegate { };     public secondpage()     {         this.initializecomponent();     }      protected override void onnavigatedto(navigationeventargs e)     {     }      private void btnclear_tapped(object sender, tappedroutedeventargs e)     {         //some works         if (clearhandler != null)             clearhandler(this, null);     } } 

in mainclass

public sealed partial class mainpage : page {     public mainpage()     {         this.initializecomponent();         this.navigationcachemode = navigationcachemode.required;     }      protected override void onnavigatedto(navigationeventargs e)     {         secondpage sp = new secondpage();         sp.clearhandler += sp_clearhandler;     }      private void sp_clearhandler(object sender, eventargs e)     {         txt.text = "";     }      private void btnjump_tapped(object sender, tappedroutedeventargs e)     {         frame.navigate(typeof(secondpage));     } } 

the textbox named txt not cleared, can guys please me, thank you!

you can use observablecollection notify 1 page another.   public static observablecollection<string> yesnostatus { get; internal set; } 

where want notify thn

yesnostatus = new observablecollection<string>();         yesnostatus.collectionchanged += yesnostatus_collectionchanged; 

and event method like:-

private void yesnostatus_collectionchanged(object sender, notifycollectionchangedeventargs e)     {         observablecollection<string> obssender = sender observablecollection<string>;     } 

add in collection after operation completed ..thn notify.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -