You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to draw a semi-transparent overlay over the entire screen.
screenshot of the feature working in Xamarin
The most obvious solution is to use an AbsoluteLayout + GraphicsView. However, this doesn't work because Xamarin/Maui don't allow AbsoluteLayout to draw things over the NavigationPage navigation bar.
The solution in Xamarin was to write a custom NavigationPageRenderer and override DispatchDraw
[assembly: ExportRenderer(typeof(NavigationPage), typeof(MyNavigationPageRenderer))]
public class MyNavigationPageRenderer : NavigationPageRenderer
{
...
protected override void DispatchDraw(Canvas screenCanvas)
{
base.DispatchDraw(screenCanvas);
// Custom drawing code here - screenCanvas can draw on the entire screen
}
}
Use a Maui handler. However, these seem to be significantly less powerful than renderers. There is no way to override methods on native controls; there is no draw event to hook into on either the native or platform control; and there is no draw command in the CommandMapper. So I can't figure out any way to draw things.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
(Cross posted to Stackoverflow here)
I would like to draw a semi-transparent overlay over the entire screen.
screenshot of the feature working in Xamarin
The most obvious solution is to use an
AbsoluteLayout
+GraphicsView
. However, this doesn't work because Xamarin/Maui don't allowAbsoluteLayout
to draw things over theNavigationPage
navigation bar.The solution in Xamarin was to write a custom
NavigationPageRenderer
and overrideDispatchDraw
In Maui, you have two choices:
Use a compatibility renderer via
.AddCompatibilityRenderer
. However, as far as I can tell, these are just completely broken. Even a completely empty one crashes the app.Use a Maui handler. However, these seem to be significantly less powerful than renderers. There is no way to override methods on native controls; there is no draw event to hook into on either the native or platform control; and there is no draw command in the
CommandMapper
. So I can't figure out any way to draw things.So, how can this feature be implemented in Maui?
Beta Was this translation helpful? Give feedback.
All reactions