Show child window before InitializeComponent

2019-08-03 09:57发布

问题:

I have Silverlight application i want to show login window before main page InitializeComponent();

this method does not works:

public MainPage()
        {
            Login log = new Login();
            log.Show();
            InitializeComponent();
        }

Any advice?

回答1:

Try this:

public MainPage()
        {

            InitializeComponent();
            Loaded += MainPage_Loaded;
        }

 private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            Visibility = Visibility.Collapsed;
            Login log = new Login();
            log.Show();
        }