Forum Discussion

cimframe's avatar
cimframe
Copper Contributor
Mar 07, 2022

How does PointerOver work when no controls seem to emit any event indicating Pointer Enter Leave

When I look at the flyout menu for a desktop application, I can see a very slight grey color behind the tab header indicating it knows the pointer is over that tab header.  When the pointer is moved, the PointerOver works on the next header, etc.  Also, I have been trying to get a button to react to PointerOver events, but it doesn't seem to work either.  I attached a Pressed and Released event handler to a button so that I could change the color of the button when the button is pressed.  The color does not change until the mouse button is released but the pointer still remains over the button.  When the pointer is moved away and out of the boundary of the button, the button's color returns to Normal state (I have also done the same detection with the Visual State Manager).  The fact that the color returns to normal when the pointer is moved off the button seems to be reacting to a Pointer[Not]Over event, but I cannot find any control that emits an event.  This was easy to do in WPF because the WPF controls recognized when a mouse entered, hovered, and left the control's airspace.  How is this supposed to be done in .NET Maui???

 

Here is some xaml with the visual state manager code applied:

 

 

<VisualStateManager.VisualStateGroups>
	<VisualStateGroup
		x:Name="CommonStates">
		<VisualState
			x:Name="Normal">
			<VisualState.Setters>
				<Setter
					Property="Button.BackgroundColor"
					Value="White" />
			</VisualState.Setters>
		</VisualState>
		<VisualState
			x:Name="Pressed">
			<VisualState.Setters>
				<Setter
					Property="Button.BackgroundColor"
					Value="{StaticResource Grey3}" />
			</VisualState.Setters>
		</VisualState>
	</VisualStateGroup>
</VisualStateManager.VisualStateGroups>

 

 

Either I am missing something or there is a bug.  I realize the bulk of the Maui code is being ported from Xamarin which really does not have a "desktop" type workflow so mousing looks like a second-class citizen here.

 

Bottom line is how do you get mouse enter, mouse hover, and mouse leave to work like it did in WPF?

No RepliesBe the first to reply

Resources