In my application, I have a class Chronometer which use a dispatcherTimer and Tick method. Each second, a variable decrease.
I would like that when the value of the variable is 0, a new xaml page is load.
I try to use NavigationService
but this method work only in a xaml.cs file.
My xaml page which is visible when the variable decrease is : WordPage.xaml The xaml page that i want to display is : FinalPage.xaml
Can you realize what I want? Please help me
EDIT :
My constructor of my class is :
public Chrono(DispatcherTimer newTimer, TextBlock chrono, TextBlock NumEquip, P1 page1)
{
//Part effaced
m_page1 = page1;
}
and the instanciation of the object Chrono is :
MonChrono = new Chrono(newTimer, this.TimeLabel, this);
Use RootFrame in App.xaml
You cannot create an instance of NavigationService, that's the main problem. But you could possibly pass your page object as a parameter and access its
NavigationService.Property
Sample project: http://www.abouchleih.com/wp-content/uploads/TestNavigationFromClass.zip
Edit: I found a better solution. Don't pass the page object, bette pass it's NavigationService-Property, now you can simply call the same method from multiple pages.
Method in your class:
Call from a page: