-
- RisingSunStudios
- Posts: 21
- Joined:
Bug with ListBox keyboard navigation
Hey!
I've noticed in my own samples as well as the official samples that it appears as if the ListBox is focused by default, and requires 2 presses of the Down arrow before the focus is moved to the first ListBoxItem. I've tried forcing focus to the first ListBoxItem but then I get a strange behaviour with an outline around the ListBoxItem as if it has focused the container despite it not being Focusable. I have copied the QuestLog sample.
You can see this in the QuestLog sample here https://www.noesisengine.com/xamltoy/61 ... 2b96e30f94
If you load the sample and make sure you don't mouse-over any list items, it requires 2 down-button presses to move the selection.
Anyone have any idea why? It is quite an annoying bug!
Many thanks!
I've noticed in my own samples as well as the official samples that it appears as if the ListBox is focused by default, and requires 2 presses of the Down arrow before the focus is moved to the first ListBoxItem. I've tried forcing focus to the first ListBoxItem but then I get a strange behaviour with an outline around the ListBoxItem as if it has focused the container despite it not being Focusable. I have copied the QuestLog sample.
You can see this in the QuestLog sample here https://www.noesisengine.com/xamltoy/61 ... 2b96e30f94
If you load the sample and make sure you don't mouse-over any list items, it requires 2 down-button presses to move the selection.
Anyone have any idea why? It is quite an annoying bug!
Many thanks!
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: Bug with ListBox keyboard navigation
Hi, when the sample is loaded the focus is in the page, the first key down moves the focus to the first item in the list (you can see it by adding a FocusVisualStyle to the ListBoxItem style), and the second key down moves the selection to the second item.
But you can place the focus at the ListBox when the page gets loaded if that is what you need. Just add a SetFocusAction to an EventTrigger for the Loaded event:
Is this what you're looking for?
But you can place the focus at the ListBox when the page gets loaded if that is what you need. Just add a SetFocusAction to an EventTrigger for the Loaded event:
Code: Select all
<ListBox x:Name="Quests" Style="{StaticResource QuestListStyle}"
ItemContainerStyle="{StaticResource QuestListItemStyle}"
ItemsSource="{Binding Children, Source={StaticResource Quests}}"
SelectedIndex="0"
DisplayMemberPath="Tag">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<noesis:SetFocusAction/>
</i:EventTrigger>
<i:EventTrigger EventName="SelectionChanged">
<ei:ControlStoryboardAction Storyboard="{StaticResource QuestSelected}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ListBox>-
- RisingSunStudios
- Posts: 21
- Joined:
Re: Bug with ListBox keyboard navigation
Hey thanks, I can't test this right now but I'll try it in the next week when back at my desk. I tried setting focus but got strange behaviour where the focus style and liet selection was out of sync. Maybe my mistake was trying to set focus to the listboxitem instead of the listbox on loaded.
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: Bug with ListBox keyboard navigation
Setting the focus in the ListBoxItem style would be more tricky, as it will try to do it for all the items in the list unless you add some kind of ConditionBehavior in addition to the use of AlternationIndex to only do it for the first item, and it doesn't seem necessary in this scenario as you can just focus the ListBox.
Anyway, our QuestLog sample in XamlToy is an old version (compared to the ones provided in our SDKs) and it was not right, we fixed it to set the focus in the list as expected.
Anyway, our QuestLog sample in XamlToy is an old version (compared to the ones provided in our SDKs) and it was not right, we fixed it to set the focus in the list as expected.
-
- RisingSunStudios
- Posts: 21
- Joined:
Re: Bug with ListBox keyboard navigation
Perfect, thank you! I'll check it out as soon as I'm home. Really appreciating Noesis so far in our current project!
-
- RisingSunStudios
- Posts: 21
- Joined:
Re: Bug with ListBox keyboard navigation
Just confirming that setting focus to the listbox worked! Could have sworn I tried that but oh well - thanks very much for the assistance =)
Re: Bug with ListBox keyboard navigation
Thank you for the feedback!
Who is online
Users browsing this forum: No registered users and 3 guests