我有 2 个页面,我需要将 mainpage.xaml 导航到 login.page xaml,但它让我崩溃你调用的对象是空的。在 Root.Children.Clear();....
我在 App.xaml 中添加了以下代码:
private void Application_Startup(object sender, StartupEventArgs e)
{
Grid myGrid = new Grid();
myGrid.Children.Add(new MainPage());
this.RootVisual = myGrid;
}
然后我在 main.xaml 上添加了一些代码以导航到 LogonUI.xaml
namespace Gen.CallCenter.UI
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
Grid Root = ((Grid)(this.Parent));
Root.Children.Clear();
Root.Children.Add(new LoginUI());
}
}
}
如何将 main.xaml 导航到 LoginUI.xaml ?
假设您正在查看MainPage.xaml
然后你想打开另一个名为的 xaml 页面newPage.xaml
通过单击Button
or an ImageEdit
in the MainPage.xaml
,这是您应该在其中编写的快速解决方案MainPage.xaml.cs
:
private void imageEdit1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
newPage mynewPage = new newPage(); //newPage is the name of the newPage.xaml file
this.Content = mynewPage;
}
这是和我一起工作的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)