I want to detect mouse hovering over visual elements in .NET MAUI ( like buttons ). I cannot find any "onmouseover"/"ismouseover" events for this. How can I implement this.
All requests for "desktop" style control of keyboard and mouse have been consolidated under Proposed Keyboard/Mouse Specs for .NET8.
jfversluis' comment (at that issue or a related issue) indicates that no work in this area has yet been planned.
That issue is the place to discuss the topic (express interest in, or add any specific requirements or use cases), until there is a plan.
Until then, the work-around is generally to write Windows-only code in the Windows folder of your Maui project.
Unfortunately for mouse, that only gives window or desktop-relative mouse information. AFAIK, There currently is no easy way to interact with individual UI elements while the mouse moves. (Because Maui started as Xamarin started as mobile cross-platform code; touch devices don't have concept of cursor being moved around screen.)
A crude hack is to use AbsoluteLayout: position UI elements at exact positions, so you know where they are, then write (Windows-only) code that does your own "detection".
The next level of sophistication would be to write code that traverses a window's "visual tree" of UI elements, to detect what control the mouse is over. Maui must have such logic internally somewhere, to handle touch events. Unless it relies on each platform's UI code to decide that. TBD.
For now, Maui makes sense for apps that can live with a "touch" paradigm, rather than a "desktop" paradigm.
This worked for me on the WINDOWS platform
XAML
<Button x:Name="addServerBtn"
Text="+"
BackgroundColor="DarkSlateBlue"
Loaded="addServerBtn_Loaded"
ToolTipProperties.Text="Add new server" />
Code
private void addServerBtn_Loaded(object sender, EventArgs e)
{
#if WINDOWS
var btn = (Element)sender;
var btnViewHandler = (ButtonHandler)btn.Handler;
var btnColor = ((Button)btn).BackgroundColor;
btnViewHandler.PlatformView.PointerEntered += (s, e) =>
{
((Button)btn).BackgroundColor = Colors.CornflowerBlue;
};
btnViewHandler.PlatformView.PointerExited += (s, e) =>
{
((Button)btn).BackgroundColor = btnColor;
};
#endif
}
I only needed to cast the element to the generic Element type and use the available PlatformView event handler for pointer entry and exit on the element and it works.
Notes:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With