C
C#2y ago
.rev1k

❔ How to close window in WinUI 3

I have an app that consists of 2 parts. 1st part is Login form, where user needs to enter login and password. If they are correct, it start "Editor" window where user can work. For now in order to launch second window I use:
var editorWindow = new EditorWindow();
editorWindow.Activate();
var editorWindow = new EditorWindow();
editorWindow.Activate();
The problem is that Login window is still there, and while it is not critical, I still want to close it after Login is done. First time I tried to add Window.Close() after opening the 2nd window in the .cs file of 1st Window, so
var editorWindow= new EditorWindow();
editorWindow.Activate();

var oldWindow = new MainWindow();
oldWindow.Close();
var editorWindow= new EditorWindow();
editorWindow.Activate();

var oldWindow = new MainWindow();
oldWindow.Close();
Which resulted Attempted to read or write protected memory eror. I tried to do it in the 2nd Window .cs file like this:
this.InitializeComponent();

var oldWindow = new MainWindow();
oldWindow.Close();
this.InitializeComponent();

var oldWindow = new MainWindow();
oldWindow.Close();
Which resulted the same error So how can I do this properly?
1 Reply
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server