简体   繁体   English

如何基于上一个窗口按钮显示网格单击WPF c#

[英]How to show a grid based on previous window button click WPF c#

I have a button button UpdatePatient on the window MainMenuWindow . 我在MainMenuWindow窗口上有一个按钮button UpdatePatient 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 . 我想按钮做的是显示PatientMainWindow以及对电网PatientMainWindow和更改标签的内容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. gridHidden_True()只是我在当前窗口上隐藏网格的一种方法。

When the new window displays the label content does not change and the grid is not set to visible. 当新窗口显示时,标签内容不会更改,并且网格不会设置为可见。

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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM