在WPF中应该一次只打开一个窗口吗? [英] Only one windows should be open at once in WPF?

查看:25
本文介绍了在WPF中应该一次只打开一个窗口吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 vb.net 中开发一个 WPF 项目,其中有多个窗口.当用户选择一个菜单项时,会打开一个新窗口,问题是当用户单击其他菜单项时,当前窗口应该自行关闭.我如何实现它?谢谢!

I am developing a WPF project in vb.net and have multiple windows in it. When user selects a menu item a new windows opens and the problem is when the user clicks on other menu item the current window should close by itself. How do i achieve it? Thanks!

推荐答案

我认为您的意思是基于您的评论:

I think you mean this based upon your comment:

Class MainWindow 

  Public Win3 As Window3 = New Window3()

  Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
    Win3.Show()
    Me.Close()
  End Sub

End Class

这篇关于在WPF中应该一次只打开一个窗口吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆