Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
一个WPF应用程序中有两个窗口_Wpf_Vb.net_Windows - Fatal编程技术网

一个WPF应用程序中有两个窗口

一个WPF应用程序中有两个窗口,wpf,vb.net,windows,Wpf,Vb.net,Windows,WPF&VB.NET 我有一个有两个独立窗口的应用程序。一个用于登录的窗口,下一个是主应用程序窗口 当我点击登录验证按钮时,若凭证正确,那个么登录窗口应该关闭,主应用程序窗口应该打开。 为此,我编写了代码 Private Sub Verify_Click(sender As Object, e As RoutedEventArgs) Handles Verify.Click Dim Home As New MainWindow() Home.Show() Applicat

WPF&VB.NET

我有一个有两个独立窗口的应用程序。一个用于登录的窗口,下一个是主应用程序窗口

当我点击登录验证按钮时,若凭证正确,那个么登录窗口应该关闭,主应用程序窗口应该打开。 为此,我编写了代码

Private Sub Verify_Click(sender As Object, e As RoutedEventArgs) Handles Verify.Click
    Dim Home As New MainWindow()
    Home.Show()
    Application.Current.MainWindow = Home
    Me.Close()
End Sub
主页=>主应用程序窗口

Me=>登录窗口

起初,这是可行的。但现在它显示了一个例外

PresentationFramework.dll中首次出现类型为“System.Windows.Markup.XamlParseException”的异常

Additional information: 'Add value to collection of type System.Windows.Controls.UIElementCollection' threw an exception.
两个窗口都有此样式:

WindowStyle="None"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
WindowState="Maximized"
AllowsTransparency="True"
请引导通过…

登录窗口, WindowsStartUpLocation=“CenterScreen”正常

主窗口,删除WindowsStartUpLocation=“CenterScreen”


进行此更改后,第二个窗口的XAML将出错。找出问题并解决。是的,我试过了。但是当我单独运行第二个窗口时,xaml中没有错误。异常可能会在某处给您一个行号。是的,第112行位置10您可以编辑问题并指向/粘贴导致此问题的行!!!该位置不会导致异常。