The best approach to showing / hiding windows individually

I am a student and am creating a WPF application in C #. It has three windows:

  • Enter the window

  • Create Account Window

  • and the main application window.

I uploaded a shape to show the type of navigation I'm trying to implement:

http://picturepush.com/public/8870554

I don’t think it’s correct for the window to show / hide inside the close / load event of another window.

  • Can someone show me the correct way to implement this navigation?

  • Also, is it okay to make three private properties of an application class window?

  • The last window has a frame control to support page navigation. Again, is it better to make the three pages private properties of the MainWindow application?

I'm sorry if this is so obvious or easy to do. Thanks

+5
source share
4

. .

, , .

if (logonSuccess)
{
    var mainWindow = new MainWindow();
    mainWindow.Closed += ReshowSignupWindow;
}

. , , , , , .

:.

// In sign-in window, handle the create window being closed
private void CreateWindowClosedHandler(object sender, EventArgs e)
{
    if (accountCreatedOK)
    {
        ShowMainWindow();
    }
    else
    {
        ReshowSignupWindow();
    }
}

, ShowDialog().

, ...

0

- (, visual studio ) XAML . RegistrationDialog , .

<Window x:Class="WpfApplication1.LoginWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="LoginWindow">
    <StackPanel>
        <Button IsDefault="True" Content="Submit" Click="SubmitButton_Click"/>
        <Button IsCancel="True" Content="Cancel" />
        <Button Content="CreateAccount" Click="CreateAccountButton_Click"/>
    </StackPanel>
</Window>

//Handler of LoginWindow and RegistrationWindow
private void SubmitButton_Click(object sender, RoutedEventArgs e)
{
    this.DialogResult = true;
}

//Handler of LoginWindow only
private void CreateAccountButton_Click(object sender, RoutedEventArgs e)
{
    this.IsCreatingAccount = true;
    this.DialogResult = false;
}

public partial class App : Application
{
    protected override void OnStartup(StartupEventArgs e)
    {
        bool isCanceled;

        while (loginWin.ShowDialog() == false && !isCanceled)
        {
            if (loginWin.IsAccountCreationRequested)
            {
                if (registrationWin.ShowDialog())
                {
                    isCanceled = true;
                }
                else
                {
                    loginWin.IsAccountCreationRequested = false;
                }
            }
            else
            {
                isCanceled = true;
            }
        }

        if (loginWin.DialogResult) MainWindow.Show();
    }
}
0

Silverlight, . , 2 xaml ( ). , . TabControl , 3 xaml (Page1.xaml, Page2.xaml Page3.xaml). , - .

, .

0

All Articles