I have some button that I want them to be hidden when the wpf loads up. I use this:
public MainWindow()
{
mySendButton.Visibility = Visibility.Hidden;
myReceiveButton.Visibility = Visibility.Hidden;
InitializeComponent();
}
But the above generating an error. i think I wrote them not at the right place. Can I get a help please?
InitializeComponentMethod initializes the components, in your case buttons. Your buttons beforeInitializeComponentcall isnullbecause they are not initialized and setting its visibility throws the exception.That's why in some languages it is written
You need to do
BTW, you can set the visibility in XAML like this.