I have set the Visibility
property of the main window to Hidden
and added the following in Window_Loaded
:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
this.Visibility = System.Windows.Visibility.Visible;
}
But it doesn't show up the Window. Any specific reason for this?
The window is not loaded until it is shown, as per your code it will not be shown until it is loaded. Obivously this cannot work like that, right?
I was having an issue with this as well and it seems changing the visibility alone on a main window doesn't work as H.B. pointed out. For my case, I wanted to not show the window until it was completely loaded and was able to achieve that by using the property I've linked to here, along with the Show() and Hide() functions on the Window object. System.Windows.Window.ShowActivated
this.ShowActivated = false;
this.Hide();
this.Show();
It is also possible in some WPF apps for the this
reference not to work as expected, however if this is the case go to the XAML and find the name property of the window. You should be able to ref the window from the code via that name. Ex.
<Window x:Name="MainWindow">
//Code Behind Below
MainWindow.ShowActivated = false;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With