Back to Devexpress

OnDisplaySizeExtension Class

maui-devexpress-dot-maui-dot-core-bfd62efe.md

latest3.8 KB
Original Source

OnDisplaySizeExtension Class

Implements a XAML extension that allows you to specify control settings (for example, the font size) depending on the physical screen size, regardless of the screen orientation.

Namespace : DevExpress.Maui.Core

Assembly : DevExpress.Maui.Core.dll

NuGet Package : DevExpress.Maui.Core

Declaration

csharp
public class OnDisplaySizeExtension :
    MarkupExtensionBase<object>

Remarks

The following example shows how to select the font size of a DXButton ‘s text depending on the device screen size:

xaml
<ContentPage ...
             xmlns:dx="clr-namespace:DevExpress.Maui.Core;assembly=DevExpress.Maui.Core">
    <!--...-->
        <dx:DXButton Content="Click"
                           FontSize="{dx:OnDisplaySize ExtraSmall='10', Small='12', Medium='14', Large='16', ExtraLarge='18'}"/>
    <!--...-->
</ContentPage>

The table below describes different size classes and their breakpoints in logical (device-independent) pixels:

Size classBreakpoints
ExtraSmallheight < 360, width < 640
Smallheight ≥ 360, width ≥ 640
Mediumheight ≥ 375, width ≥ 732
Largeheight ≥ 428, width ≥ 853
ExtraLargeheight ≥ 768, width ≥ 1024

The height is calculated as follows: Pixel height / Density
The width is calculated as follows: Pixel width / Density
Refer to the following page for more information: Device display information.

See the following help section for sample devices of each size class: Size Class Classification.

To change the size class breakpoints, use the following properties:

In C# code, you can use the ON.DisplaySize method to set values depending on the screen size.

Implements

IMarkupExtension\

IMarkupExtension

Inheritance

System.Object DevExpress.Maui.Core.Internal.MarkupExtensionBase
OnDisplaySizeExtension

Extension Methods

Yield<OnDisplaySizeExtension>()

YieldIfNotNull<OnDisplaySizeExtension>()

See Also

OnDisplaySizeExtension Members

OnScreenHeightExtension

OnScreenWidthExtension

Specify Device-Specific Settings

DevExpress.Maui.Core Namespace