I'm porting a Winform project to WPF and started working with Windows & Pages (using the frame control). Basically my intention is to navigate from one page to the next until the user logs in successfully. Now since the logIn is handled at the Page level... my question is:
How can the Page Shut Down the Parent Window?!?
Thanks in advance if you know the code in vb. If not I'll figure it out in C#.
Public Sub CloseLogIn()
Dim LogIn = TryCast(Me.Parent, Window)
If LogIn IsNot Nothing Then
LogIn.Close()
End If
End Sub
Try
Public Sub CloseLogIn()
Dim LogIn = Window.GetWindow(Me)
If LogIn IsNot Nothing Then
LogIn.Close()
End If
End Sub
The Window.GetWindow() method returns a reference to the Window object that hosts the content tree within which the dependency object is located.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With