Am currently working on a uwp project involving the use of a hamburger menu. So far I generated the menu using this code
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph=""
Foreground="Black" VerticalAlignment="Center" Margin="12,0,8,0">
What I really what to achieve is that when the mouse hovers on the icon, the background colour of the hamburger menu is expected to change. This is similar to a minimize button in a windows app. After searching the API I realised that there wasn't any mousehover event and I think the closest thing to it was a PointerEnetered event. How do I achieve this with the PointerEntered event in XAML?
Update You cant do that in XAMl. If you want to do in XAMl Use button instead and edit Visual state of Button
You can do like this
In addition to the solution that has been posted by @Archana to change the foreground color of the FontIcon, for changing the hamburger menu’s background color and let it to be similar to a minimize button in a windows app, we can try to add the FontIcon xaml into the Button’s content and change the Button’s background color to let it look like that we have changed the hamburger menu’s background color.
For handling the mousehover event, as you have said we need to use the PointerEnetered event. But please do not forget to handle the PointerExited event to let the hamburger menu’s background color come back to normal after we do not move the mouse over the hamburger menu .
For more information, please check my sample:
XAML code:
CS code:
If you only want to implement it by using XAML, please right click the Button to edit the Button style and change the background color of the Button inside the PointerOver VisualState as following:
For the completed XAML code, please check:
The result:
Thanks.