Question: Can mouse enter/leave be detected for a specific item (selected item) in UWP ListBox? #7501
Replies: 6 comments
-
Have you tried looking at the ListBoxItem? |
Beta Was this translation helpful? Give feedback.
-
Do you mean putting ControlTemplate for ListBoxItem inside ListBox xaml? |
Beta Was this translation helpful? Give feedback.
-
Is there a ListBoxItem 'PointerExited' Visual State? |
Beta Was this translation helpful? Give feedback.
-
The ListBoxItem moves from the PointerOver state back to the Default/Rest state? Looking at the docs, all UIElements have a PointerExited event |
Beta Was this translation helpful? Give feedback.
-
Indeed, the UIElements do have a PointerExited event. Where would I find an example of the PointerExited event implementation for a UWP ListBoxItem? |
Beta Was this translation helpful? Give feedback.
-
ListBox is a pretty old control, I'd recomend using ListView instead if possible. However attaching to the PointerExited event of your ListBoxItem should be pretty easy. I don't have an example on hand but if you have retrieved the ListBoxItem as a local variable it should be as easy as:
We have examples where we do this for other controls in the repo: If you are having trouble getting the item yourself you might need this https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.itemscontrol.containerfromitem?view=winrt-19041 What is your scenario? This shouldn't really be needed. |
Beta Was this translation helpful? Give feedback.
-
I'm using a UWP ListBox and would like to be able to detect when the mouse pointer enters / leaves the SelectedItem in ListBox list.
The ListBox does have an associated PointerExited event, but that is for the whole ListBox itself.
I need to detect the mouse pointer on the specific item.
Beta Was this translation helpful? Give feedback.
All reactions