Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Avoid NullRefereceExceptions when no document open#57

Open
mrlacey wants to merge 2 commits into
dotnet:dev from
mrlacey:i56-NREs
Open

Avoid NullRefereceExceptions when no document open #57
mrlacey wants to merge 2 commits into
dotnet:dev from
mrlacey:i56-NREs

Conversation

@mrlacey

@mrlacey mrlacey commented Jan 8, 2026
edited
Loading

Copy link
Copy Markdown

Fixes 56

Fixes #56

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

Can get NREs

What is the new behavior?

Avoids these exceptions by adding suitable null checks.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest dev branch of XAML Studio
  • Tested code with current supported SDKs
  • Contains NO breaking changes to save/state files

Other information

Copy link
Copy Markdown
Contributor

Thanks @mrlacey! Took me a second to realize what you meant issue, but I see now about clicking on the main navigation view items. You're actually not supposed to be able to click on them without a document loaded... 😅

Looks like in the change to #3 that I broke the logic for ViewModel.IsEditingDocument in the MainViewModel somehow which should disable those buttons:

<muxc:NavigationViewItem x:Uid="MainPage_NavMenu_DataSources"
IsEnabled="{x:Bind ViewModel.IsEditingDocument, Mode=OneWay}"
Tag="DATASOURCES">
<muxc:NavigationViewItem.Icon>
<lcontrols:AppFontIcon IconName="Wheel" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="MainPage_NavMenu_Debug"
IsEnabled="{x:Bind ViewModel.IsEditingDocument, Mode=OneWay}"
Tag="DEBUG">
<muxc:NavigationViewItem.Icon>
<lcontrols:AppFontIcon IconName="Bug" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="MainPage_NavMenu_Properties"
IsEnabled="{x:Bind ViewModel.IsEditingDocument, Mode=OneWay}"
Tag="PROPERTIES">
<muxc:NavigationViewItem.Icon>
<lcontrols:AppFontIcon IconName="Properties" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="MainPage_NavMenu_Toolbox"
IsEnabled="{x:Bind ViewModel.IsEditingDocument, Mode=OneWay}"
Tag="TOOLBOX">
<muxc:NavigationViewItem.Icon>
<lcontrols:AppFontIcon IconName="Work" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>

I see, it used to be that they were defined based on if the Welcome/Settings activity was open:

public bool IsEditingDocument => OpenActivity != "SETTINGS" && OpenActivity != "WELCOME";

The problem is you can still click on "Explorer", but then from there get to any of the others... 🤔

I think this can be fixed by ensuring the ActiveFile is set as part of this condition instead or that OpenFiles count is not zero.

Let me know your thoughts!

mrlacey commented Jan 8, 2026

Copy link
Copy Markdown
Author

If you can style them so it's clear they're not enabled then maybe do that. But then I'd wonder why they weren't enabled. I was having a poke around because I hadn't used it in a long time. I proposed a quick fix for an issue that is clearly something you're very unlikely to do once familiar with the app you are unlikely to try and do anything without a document open.

If I was you, I'd take this fix (it's rarely bad to add extra null checking) and then address what should be enabled (& when) as part of looking at improving the OOBE experience

michael-hawker reacted with thumbs up emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

NullReferenceExceptions if using the main menus with no document open

AltStyle によって変換されたページ (->オリジナル) /