How can i navigate one xaml page to another?

Posted by programmerist on Stack Overflow See other posts from Stack Overflow or by programmerist
Published on 2010-04-25T18:04:13Z Indexed on 2010/04/25 19:23 UTC
Read the original article Hit count: 550

i have 2 page i need to navigate mainpage.xaml to login.page xaml but it throws me Object reference not set to an instance of an object. in Root.Children.Clear();....

i added this codes in App.xaml:

   private void Application_Startup(object sender, StartupEventArgs e)
        {
            Grid myGrid = new Grid();
            myGrid.Children.Add(new MainPage());
            this.RootVisual = myGrid;
       }

and than i adde some codes on main.xaml to navigate to LoginUI.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());
        }
    }
}

How can i navigate main.xaml to LoginUI.xaml ?

© Stack Overflow or respective owner

Related posts about c#4.0

Related posts about Silverlight