vladc77
vladc77

Reputation: 1064

How to load content page into mainPage from another xaml page?

I have 3 separate pages MainPage.xaml, Content.xaml and Nav.xaml. I need to load a Content.xaml in 'ucMainContent' userControl that sits inside MainPage.xaml by clicking a button from Nav.xaml. I am wondering what I am doing wrong. Any advice is highly appreciated.

MainPage.xaml where I set content container with this code:

<UserControl x:Name="ucMainContent" />

I am trying to load Content.xaml into mainPage.xaml from Nav.xaml. The code from Nav.xaml page where is the button:

private void LoadContent_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
    {
        var contentPage = new Content();
        var ucMainPage = new MainPage();
        ucMainPage.ucMainContent.Content = contentPage;
    }

Upvotes: 0

Views: 961

Answers (1)

Johnv2020
Johnv2020

Reputation: 2146

If I understand you correctly you need to find the parent Control of Nav.xaml in this case Main.

Check out http://forums.silverlight.net/forums/t/55369.aspx - there is an excellent generic utility which allows you to find the parent of any usercontrol

Upvotes: 1

Related Questions