Hello,
Welcome to our Microsoft Q&A platform!
it cannot find my VM (View Model) and throws me the error
By checking your code, I got this exception in NotesPage.xaml and it is caused by SQLiteConnection in the NotesVM.cs. For example, because you don't have any data in your database, the method conn.Table< NoteBook>().ToList()
will throw the exception, so you could add try...catch
to prevent continued execution without data.
NotesVM.cs:
public void ReadNotebooks()
{
using (var conn = new SQLiteConnection(DatabaseHelper.dbFile)) {
try
{
var notebooks = conn.Table().ToList();
NoteBooks.Clear();
foreach (var item in notebooks)
{
NoteBooks.Add(item);
}
} catch (Exception ee) {
string info = ee.Message;
}
}
}
The UserID is defined as a string in the App.cs, but I am confused where to check that
When you want to check it, you can call the App.UserId
to see if it is empty or not.