Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update opening-a-dialog.md #547

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

nojuslau
Copy link

System.NullReferenceException: Object reference not set to an instance of an object."
10:09:51.696 [Error] 18512 <= " at Avalonia.MusicStore.Views.MainWindow.<.ctor>b__0_0(Action1 action) in Avalonia.MusicStore\Views\MainWindow.axaml.cs:line 14"

Either ensure that ViewModel is not nullable or add data context in constructor: DataContext = new MainWindowViewModel();

System.NullReferenceException: Object reference not set to an instance of an object."
10:09:51.696 [Error] 18512 <= "   at Avalonia.MusicStore.Views.MainWindow.<.ctor>b__0_0(Action1 action) in Avalonia.MusicStore\Views\MainWindow.axaml.cs:line 14"

Either ensure that ViewModel is not nullable or add data context in constructor:
DataContext = new MainWindowViewModel();
@thevortexcloud
Copy link
Contributor

The view model is nullable. The code that is there just assumes it never will be, which it wont 99% of the time. The only time it should be null is if you for some reason create the dialogue without giving it a view model.

In fact: adding this check may actually create additional bugs since it will silently fail to register interaction handlers when the view is activated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants