I making an upload app for Windows Phone, the function is in the class B (SecondPage), I have a upload task, when this task is completed, it call a event and notice class A (MainPage) that the task is done and do some things, looking around the site, I found some solutions but they don't help to much (just I think that).
Here are my 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 is not cleared, can you guys please help me, thank you!