Reputation: 112
I have a button button UpdatePatient
on the window MainMenuWindow
. What I want the button to do is display the PatientMainWindow
as well as the grid on the PatientMainWindow
and change the label content to Update Patient
.
private void button_updatePatient_Click(object sender, RoutedEventArgs e)
{
gridHidden_True();
PatientMainWindow patientMainWindow = new PatientMainWindow();
patientMainWindow.ShowDialog();
patientMainWindow.Grid_SelectPatient.Visibility = Visibility.Visible;
patientMainWindow.label_PatientWindowType.Content = "Update Patient";
this.Close();
}
gridHidden_True()
is just a method that I have that hides grids on the current window.
When the new window displays the label content does not change and the grid is not set to visible.
Upvotes: 0
Views: 172
Reputation: 22008
You are displaying modal window first and only then setting properties (after window is closed). You should set them first:
var patientMainWindow = new PatientMainWindow();
patientMainWindow.Grid_SelectPatient.Visibility = Visibility.Visible;
patientMainWindow.label_PatientWindowType.Content = "Update Patient";
patientMainWindow.ShowDialog();
Upvotes: 1