[英]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.