Avalonia ViewLocator not ViewLocating
I have an Avalonia project with multiple pages like MainView and LoginView and SettingsView etc, pretty standard stuff
But now I have the following problem, trying to set my
ViewModelBase.ContentViewModel
to something will result in the ContentViewModel
being null
for no apparent reason
The program workflow goes like this:
The program starts -> the program sets the DataContext
to new MainViewModel()
-> MainViewModel checks if the user is logged in to an account, if not it will set ContentViewModel
to new LoginViewModel()
, in the LoginView the user is supposed to log into an account which is then supposed to set the ContentViewModel
to a new MainViewModel()
, but instead the ContentViewModel
is null
6 Replies
How is
ContentViewModel
being bound in your view? Though that shouldn't really matter, if you're setting that property to a value, Avalonia shouldn't be setting it back to nullI just hope he is not randomly trying to access ContentViewModel property from inherited classes that dont have it initialized because only one does it
or calling
new MainViewModel()
somewhere:SCconfused:
github or close
:madcar:
It's not on github and I can't publish it yet :SCgetoutofmyhead:
But I can share the necessary code :kadse: