-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Setting a HamburgerMenu.Content is giving a nullexception error #3241
Comments
I have experienced the same. And one more thing: _ItemInvoked and _ItemClick will always raise, if I change the selection index with buttons. For example: I set the focus with Tab button to the MenuItems and change the selection with arrow buttons (up and down), then the _ItemInvoked and _ItemClick events will always raised, however I didn't clicked on the button. I think it's a problem too. |
@touyets Please create a simple sample, so I can investigate what's going on there. |
@kszabolcs Why do you think this is a problem? |
I think, the selection and the click event have to be two different event. For example let's say I don't have a mouse (ok, I know this is very extreme, but it's a possible case) and I want to click on the third menu item. Firstly I need to set the focus to the MenuItems with Tab button, then set the selection to the third button with the arrow buttons and when it will be selected then possible to raise the click event with Enter or with Space button. Currently if I move the selection the Click event will be raised on every selection change, but I want to change the hamburger menu content only on the click event and not on selection. As I know, every Windows hamburger menu works on this way (for example check the Mail or the Groove Music applications). On the other hand, you can investigate the demo application. There the situation is the same. Check HamburgerMenu_OnItemClick event in HamburgerMenuDefault.xaml.cs file. |
This HamburgerMenu uses the normal WPF ListBox which directly selects a ListBoxItem if you use the up/down/left/right keys. If you find a better solution or know a better control then let me know or create a PR to change this behavior. I know the UWP version for this (now the NavigationView) works different, but until there will be a better control or solution, the current selection/focusing behavior is ok. To prevent your nullpointer exception I changed a the inner part for the selection/clicked/invoked stuff. |
Sometimes, if i click too fast between the menus on a hamburgermenu, this section of the code behind launches a nullexception error:
I have looked at outputs and clicking the menus is delivering the correct outputs with the code below:
but the _OnNavigated part marked above will give a null error without me being able to find out why.
UPDATE: It is now happening now every time I try to go a second menu. Meaning: I click on a menu item and it works perfectly and whatever other menu item I click on next gives that null error every time.
The text was updated successfully, but these errors were encountered: