'Unhandled exception at 0x7B657FD9 (Microsoft.ui.xaml.dll)
I am trying to create a login system for a uwp(winui3) app. In the login window the user enters his credentials and on clicking the login button he/she is redirected to mainwindow. But I get an Unhandled exception error.
App.xaml.cs
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
loginpage=new LoginWindow();
loginpage.Activate();}
LoginWindow.xaml.cs
private void Login_Click(object sender, RoutedEventArgs e)
{
string query = "select * from ***** where username='" + username.Text + "' and password='" + password.Text + "'";
DataTable dt = new DataTable();
dt = Tools.getdatafromDATABASE(query);
if (dt.Rows.Count == 0)
{
//Display incorrect username and password message
}
else
{
//Redirect to MainWindow
Window mainwindow = new MainWindow();
mainwindow.Activate();
}
}
}
MainWindow.cs
public MainWindow()
{
this.InitializeComponent();
MainContent.Navigate(typeof(HomePage));
}
Solution 1:[1]
Multiple top-level windows are not supported in Win UI 3 / Windows App SDK 1.0. Maybe in 1.1, at least Microsoft promised so.
You can use a ContentDialog for your login window.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nick |
