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
Doombox
Doombox7mo ago
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 null
leowest
leowest7mo ago
I just hope he is not randomly trying to access ContentViewModel property from inherited classes that dont have it initialized because only one does it
Doombox
Doombox7mo ago
or calling new MainViewModel() somewhere
The Fog from Human Resources
:SCconfused:
leowest
leowest7mo ago
github or close :madcar:
The Fog from Human Resources
It's not on github and I can't publish it yet :SCgetoutofmyhead: But I can share the necessary code :kadse:
Want results from more Discord servers?
Add your server