Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 page.xaml 和 childwindow。我如何从 page.xaml 关闭子窗口。通过单击 page.xaml 中的按钮的示例。我如何从代码中获取这个 childWindow?
我相信 ChildWindow 对象上有一个 Close 方法。通过调用此方法,窗口将关闭。
请参阅 MSDN 文档。
将您的 ChildWindow 示例命名为 x:Name="myChildWindow" 在您的 page.xaml 按钮单击事件下在您的代码后面放这个
myChildWindow.Close();