Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF
In my WPF applcation,
 
I have MainWindow.xaml
and 2 pages like LoginPage.xaml and Export.xaml
 
I called these two pages in mainwindow using below code.
<Frame Source="LoginPage.xaml" NavigationUIVisibility="Hidden" />
<Frame Source="Export.xaml" NavigationUIVisibility="Hidden" Visibility="Hidden" />
in my loginpage we have a login screen, when user hits the login button Export page will open.
 
I am having a doubt like is this correct way of doing.
Posted 21-Jan-13 1:25am
Edited 21-Jan-13 2:29am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I am not sure if I have understood your question well, but if you want to navigate between windows will that not be event based? I mean first login should appear. After user fills the credential and click 'Login', authentication method should work. After authentication new form should appear?
 
If this is your workflow, why not use code instead of xml?
 
Like from Login buton event handler
if( Authnticate(txtUname.Text,pbPassword.Password)
{
 Window2 objWindow2=new Window2();
objWindow2.Show();
//or objWindow2.ShowDialog();
}
 
Wpf windows can be opened and closed almost the similar way of windows form.
  Permalink  
Comments
D-Kishore at 21-Jan-13 22:27pm
   
Yes i understood what you are saying,
 
At the start we planed to design all the controls in same window,like different panels.
 
I mean login in one panel and export in another panel.
 
once the mainwindow loaded we are displaying only login panel, once the authentication done we disabling the login panel and displaying export panel.
 
if we follow this at the designing time we are facing problems like send to back and bring front of the panels arrangements.
 
For this reason we planned to implement different pages in same window.Because of that i posted this question in code project.
 
thanks
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

In the Main window I used only one frame:
<window x:class="WpfApplication1CP.MainWindow" xmlns:x="#unknown">
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <grid>
        <frame source="LoginPage.xaml" navigationuivisibility="Hidden" />
     
    </grid>
</window>
 
I added two simple pages: LoginPage.xaml and Export.xaml
 
Here is Loginpage.xaml
 
<page x:class="WpfApplication1CP.LoginPage" xmlns:x="#unknown">
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      mc:Ignorable="d" 
      d:DesignHeight="300" d:DesignWidth="300"
	Title="LoginPage">;
 
    <grid>
        <label content="Login" horizontalalignment="Left" margin="130,155,0,0" verticalalignment="Top/><br mode=" hold=" />        <Button Content=" button=" HorizontalAlignment=" left=" Margin=" top=" Width=" 75=" Click=" button_click_1="/>
</grid>
 
Now in the button click event:
 
private void Button_Click_1(object sender, RoutedEventArgs e)
        {
 
            var wnd = Window.GetWindow(this);
            Grid g = (Grid)wnd.Content;
            Frame f=(Frame)g.Children[0];
 
            f.Source = new Uri("Export.xaml", UriKind.RelativeOrAbsolute);
        }
 
We obtain the parent window of Login page which is MainWindow. We obtain the appropriate child which is the placeholder of the frames ( i.e Frame). Update the Frame source.
 
Hope this helps.
  Permalink  
v2
Comments
Member 10786704 at 30-Apr-14 16:51pm
   
Now in the button click event:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 22 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100