Accessing MainWindow's controls from a user control page. WPF C#

user2376998 picture user2376998 · Jul 10, 2013 · Viewed 8.5k times · Source

I have a page transition ( a control ) in the MainWindow , I have many user control pages , I want to access the page transition in the MainWindow from my user control page ? How do I do that? I tried :

        Story page = new Story();
        NavigationService nav = NavigationService.GetNavigationService(this);
        // Navigate to the page, using the NavigationService
      //  if (nav != null)
       // { 
        //    nav.Navigate(page);
            MainWindow test = new MainWindow();
            test.pageTransition1.ShowPage(page);

    //    }

Answer

Jawahar picture Jawahar · Jul 10, 2013
Application.Current.MainWindow

Using this you can access the MainWindow from any place.