简体   繁体   English

如何将内容页面从另一个 xaml 页面加载到 mainPage?

[英]How to load content page into mainPage from another xaml page?

I have 3 separate pages MainPage.xaml, Content.xaml and Nav.xaml.我有 3 个单独的页面 MainPage.xaml、Content.xaml 和 Nav.xaml。 I need to load a Content.xaml in 'ucMainContent' userControl that sits inside MainPage.xaml by clicking a button from Nav.xaml.我需要通过单击 Nav.xaml 中的按钮,在 MainPage.xaml 内的“ucMainContent”用户控件中加载 Content.xaml。 I am wondering what I am doing wrong.我想知道我做错了什么。 Any advice is highly appreciated.任何建议都将受到高度赞赏。

MainPage.xaml where I set content container with this code: MainPage.xaml 我使用以下代码设置内容容器:

<UserControl x:Name="ucMainContent" />

I am trying to load Content.xaml into mainPage.xaml from Nav.xaml.我正在尝试将 Content.xaml 从 Nav.xaml 加载到 mainPage.xaml 中。 The code from Nav.xaml page where is the button: Nav.xaml 页面的代码在哪里是按钮:

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

If I understand you correctly you need to find the parent Control of Nav.xaml in this case Main.如果我理解正确,您需要在本例中找到 Nav.xaml 的父控件。

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查看http://forums.silverlight.net/forums/t/55369.aspx - 有一个出色的通用实用程序可让您找到任何用户控件的父级

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 MainPage.xaml 的元素访问到 uwp 应用程序中的另一个页面? - How to access element of MainPage.xaml into another page in uwp application? 如何将对象列表从MainPage.xaml发送到另一个页面 - How to send a list of object from my MainPage.xaml to another page 如何将ListView从MainPage传递到其他xaml页面? - How can I pass a ListView from MainPage to other xaml page? 我们如何将页面重定向到MainPage.xaml - How we redirect the Page to MainPage.xaml 使用导航时将值从另一个页面传递到Silverlight中的MainPage.xaml? - Pass value from another page to MainPage.xaml in Silverlight when using Navigation? 从phonegap应用程序的MainPage.xaml.cs切换html页面 - Switching the html page from the MainPage.xaml.cs of a phonegap application 如何将那个page1.html paeg从mainpage.xaml带到secondpage.xaml并在webControl浏览器上显示? - how can i take that page1.html paeg from mainpage.xaml to secondpage.xaml and show on webControl browser? 按钮可将应用程序页面从主页切换到页面1 - Button switches app page from mainpage to page 1 如何获取文本框文本从空白页到MainPage? - How can I get textbox text from Blank Page to MainPage? WPF如何从弹出页面访问MainPage元素 - WPF how to access MainPage elements from Popup Page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM