Table of Contents

Class MauiUtils

Namespace
Alternet.UI
Assembly
Alternet.UI.Maui.dll

Contains static methods and properties related to MAUI platform.

public static class MauiUtils
Inheritance
MauiUtils

Fields

ContextMenuUnderlayColorDark

Gets or sets color used as an overlay fill color when context menu is shown. This value is used when dark color mode is enabled. In order to make overlay transparent, set Transparent to this property.

ContextMenuUnderlayColorLight

Gets or sets color used as an overlay fill color when context menu is shown. This value is used when light color mode is enabled. In order to make overlay transparent, set Transparent to this property.

IsTabletModeOverride

Override value for testing or other purposes. If set, this value will be returned by IsTabletMode property.

Properties

ControlViews

Gets collection of ControlView elements added to pages of the application.

Controls

Gets collection of Control added to pages of the application inside ControlView elements.

FirstWindow

Gets the first window in the current application's window collection.

IsDarkTheme

Gets whether current application theme is dark.

IsTabletMode

Gets whether device is in tablet mode.

Pages

Gets collection of all pages in the application. If application is not yet created, returns an empty collection. Uses Windows, Page, ModalStack, NavigationStack in order to get the result.

PlatformApplication

Gets PlatformApplication.

Windows

Gets collection of all windows in the application. This is safe property and it returns an empty collection if application is not yet created.

Methods

AddAllViewsToParent(Layout)

Debug related method. Do not use directly.

AllParents(Element?)

Enumerates all parent elements of the specified VisualElement.

BindLongTap(View?, Action)

Attaches a handler to the long tap gesture event of the specified view, invoking the provided action when a long tap occurs.

BindToKeyboardVisibility(View)

Binds the specified panel to keyboard visibility changes. Height and visibility of the panel is adjusted based on keyboard state. When the keyboard is shown, the panel's height is set to the keyboard height and made visible. When the keyboard is hidden, the panel is made invisible.

BindToKeyboardVisibility(Action<KeyboardVisibleChangedEventArgs>)

Binds the specified action to keyboard visibility changes.

CloseApplication()

Closes the application.

Convert(Color)

Converts an Color to a Color.

Convert(SKTouchEventArgs, AbstractControl?)

Converts SKTouchEventArgs to TouchEventArgs.

CreateGridWithToolBarAndContent(View, View)

Creates a grid layout with a toolbar at the top and content below it.

EnumViewsToLog(Layout)

Debug related method. Do not use directly.

FillAbsoluteLayout(BindableObject)

Sets the layout flags and bounds of the specified bindable object to occupy the entire area of its parent AbsoluteLayout.

FindViewInContainer<T>(VisualElement)

Finds a view of the specified type inside a container.

GetAbsoluteLayoutChild(Page)

Gets the first AbsoluteLayout child from a Page using IVisualTreeElement.

GetAbsolutePosition(VisualElement)

Gets the absolute position of a VisualElement relative to its ancestors.

GetAbsolutePositionInParent(PointD, AbstractControl?, VisualElement)

Converts client coordinates to coordinates in one of the indirect parent views.

GetAbsolutePositionInParent(VisualElement, VisualElement)

Converts position in client coordinates to position in absolute coordinates for the specified indirect parent of the view.

GetAbsoluteRectInParent(RectD, AbstractControl?, VisualElement)

Converts rectangle specified in client coordinates to coordinates in one of the indirect parent views.

GetAllChildren<T>()

Gets collection of View elements added to pages of the application.

GetChildViewOfType<T>(IView)

Searches the visual tree of the specified parent view and returns the first child view of the specified type, if found.

GetChildren<T>(object?, bool)

Gets collection of the child elements in the specified container.

GetControlView(View?)

Gets the innermost ControlView from the specified view.

GetControlViewBackColor(View?)

Gets the background color of the control associated with the specified view, if available.

GetControlViewViaAbsoluteLayout(View?)

Gets the ControlView associated with the nearest parent AbsoluteLayout.

GetDevicePlatform()

Gets device platform.

GetDeviceType()

Gets device the app is running on, such as a desktop computer or a tablet.

GetFirstWindowPage()

Gets the current page of the first window in the application.

GetMainPageFromApplication()

Gets main page from the first window of the application.

GetObjectAbsoluteLayout(object?)

Retrieves the AbsoluteLayout associated with the specified object instance.

GetObjectPage(object?)

Retrieves the Page associated with the specified object instance.

GetObjectView(object?)

Retrieves the View associated with the specified object, if available.

GetPage(VisualElement?)

Gets the page that contains the specified view.

GetParentAbsoluteLayout(Element?)

Retrieves the nearest parent AbsoluteLayout that contains the specified view.

GetParentPage(AbstractControl?)

Gets parent Page for the specified control. If control is not attached to the parent, this function returns main page.

GetRootChild(Page)

Retrieves the root child element of the specified Page.

GetSpecialParent<T>(Element?)

Searches for the closest parent of type T in the view hierarchy.

GetTopAbsoluteLayout(Element?)

Retrieves the highest-level parent AbsoluteLayout that contains the specified element.

GetTopSpecialParent<T>(Element?)

Searches for the highest-level parent of type T in the element hierarchy.

HasAbsoluteLayoutInParents(Element?)

Determines whether any parent of the specified element uses an absolute layout.

HideContextMenus(View?)

Hides any visible context menus associated with the specified view.

HideContextMenusInControlView(ControlView?)

Hides context menus in the specified ControlView, if any are present.

HideViewsInContainer<T>(VisualElement?, Type?)

Hides all child views of the specified type within the given container.

ImageSourceFromImage(Image?)

Converts an Image to an SKBitmapImageSource.

ImageSourceFromSvg(SvgImage?, int, bool)

Creates ImageSource with disabled images from the specified SvgImage.

ImageSourceFromSvg(SvgImage?, int, bool, bool)

Creates ImageSource from the specified SvgImage.

IsAndroid()

Checks whether device platform is Android.

IsFullyVisibleInParent(IView)

Checks whether the specified view is fully visible within its parent.

IsIOS()

Checks whether device platform is iOS.

IsMacCatalyst()

Checks whether device platform is MacCatalyst.

IsMacOS()

Checks whether device platform is macOS.

SetButtonImage(Button, SvgImage?, int, bool)

Sets the image for a Button using the specified SVG image and size.

SetButtonImage(ImageButton, SvgImage?, int)

Sets the image for a ImageButton using the specified SVG image and size.

SetChildBoundsAbsoluteLayout(BindableObject, Rect, AbsoluteLayoutFlags)

Sets the layout bounds and flags for a child element within an AbsoluteLayout.

SetContextMenu(View?, ContextMenuStrip)

Sets the context menu for the specified view. If the view is a ControlView, its context menu is assigned directly. Otherwise, the ContextMenuStrip is converted to MenuFlyout and assigned to the view.

SetWindowSoftInputModeAdjust(Window?, bool)

Sets soft input mode for the window.

ShowContextMenu(ContextMenu?, View?, HVDropDownAlignment?)

Displays the context menu for the specified view, if supported.

SuppressMenuBarFocus()

Disables focus-related interactions for the menu bar on supported platforms.

TrySetFocusWithTimeout(object?)

Attempts to set focus on the specified object within a predefined timeout period.