Click here to Skip to main content
15,894,740 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on a vs2010 WPF project
and I'm currently working on login
login is ok but after that the supposedly MainWindow is Blank(but i designed it in Designer)

C#
Project.MainWindow main = new Project.MainWindow();
                    App.Current.MainWindow = main;
                    this.Hide();
                    main.Show();
                    this.Close();


MainWindow that i Called Show only Blank(WhiteScreen)with Border
XML
Height="550" Width="1000" AllowsTransparency="True" ResizeMode="NoResize" Topmost="True" WindowStyle="None">

but i set it without border.





as I searched google for answer
to switch Wpf window
C#
MainWindow main = new MainWindow();
    App.Current.MainWindow = main;
    this.Close();
    main.Show();


i don't know but why my MainWindow is Blank?
Posted
Comments
[no name] 9-Aug-14 11:28am    
"why my MainWindow is Blank?", could be any number of reasons. Nothing you have presented here would lead anyone to believe that your MainWindow would actually contain anything at all.
Sergey Alexandrovich Kryukov 9-Aug-14 22:48pm    
What is "this" in this fragment? Why those manipulations? Where Application.Run is called? You just don't show appropriate context of your problem, which looks quite easy.
—SA

hello try this :

Project.MainWindow main = new Project.MainWindow();
main.Owner = this;
this.Hide();
main.Show();


in the second form in the constructor don't remove this :

InitializeComponent(); 


and the second form on the event close add this to show the main form again mean the login one :

this.Owner.Show();
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 9-Aug-14 22:50pm    
Not quite clear. It depends in what context this code is... The same goes about the OP's code.
—SA
I'm quite Speechless
Jokler.007 is right
To Load the Data/Design of the Window,
one should never forget to Inialize it's Component. because if not, it will be Blank.


MainWindow.xaml.cs
C#
public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent(); 
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

        }

    }
}


Sorry I'm just new to C#
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900