✅ Not Quite Understanding Model Usage
In my view model, I am trying to use the styles that are attached to the user model, however, I keep getting the error on
UserCustomSettings.UserStyles.FontSize
saying 'Object reference not set to an instance of an object'
. Like I understand that means I have to do UserStylesModel userStyles = new()
but I don't want to overwrite what's pulled from the database so how do I fix this? Thanks.4 Replies
Pass the value of
User.CustomSettings.UserStyles
, when it's ready, to the SetupUI method
Or call SetupUI when UserStyles is ready or when their values changewell see I use this method of updating the changes. Before this view model shows, the MainWindowViewModel calls the default user's information from the database
even tried this and still got the same error
seems to have fixed it. tyvm
https://pastebin.com/mm09JnEQ I'm getting the same error in this function as well, but it's a different use case. I don't have a function to pass it off to like I did in the view model so how do I fix the
'Object reference not set to an instance of an object'
error here on line UserSettingsModel defaultUserSettings = defaultUser.CustomSettings.UserSettings;
?Either defaultUser, CustomSettings or UserSettings is null
I'm using breakpoints, and everything that is supposed to have a value has it's correct value. It's just saying that
UserSettingsModel defaultUserSettings = defaultUser.CustomSettings.UserSettings;
is not set to an instance of an object. This was the problem in the view model and when I passed the defaultUser.CustomSettings.UserSettings
through SetupUI()
's parameters, it solved that issue, however, now I'm in my Database file and I don't have any functions to pass this off to and I don't know how to fix it unfortunately
unless I need to create a get/set for the User again. let me try that
cant' do that since the class isn't a view model base, reactive ui is useless
actually it doesn't matter. I just realized my Helpers class has a GetDefaultUser() function in it that returns the default user profile in a UserModel already. Thanks though!