![](/img/trans.png)
[英]How to access element of MainPage.xaml into another page in uwp application?
[英]How to load content page into mainPage from another xaml page?
我有 3 個單獨的頁面 MainPage.xaml、Content.xaml 和 Nav.xaml。 我需要通過單擊 Nav.xaml 中的按鈕,在 MainPage.xaml 內的“ucMainContent”用戶控件中加載 Content.xaml。 我想知道我做錯了什么。 任何建議都將受到高度贊賞。
MainPage.xaml 我使用以下代碼設置內容容器:
<UserControl x:Name="ucMainContent" />
我正在嘗試將 Content.xaml 從 Nav.xaml 加載到 mainPage.xaml 中。 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;
}
如果我理解正確,您需要在本例中找到 Nav.xaml 的父控件。
查看http://forums.silverlight.net/forums/t/55369.aspx - 有一個出色的通用實用程序可讓您找到任何用戶控件的父級
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.