On Device Type

This is deprecated in Rock Mobile V6 and later. There is a built-in XAML extension for .NET MAUI.

Similar to the On Device Platform, this extension lets you change property values and entire nodes depending on what type of device the app is running on. A good use case for this would be if you want to display a different image on tablets than you do on phones.







The value to be used when the device is a phone.



The value to be used when the device is a tablet.



The value to be used when the device is something else.


<Image Source="https://www.rocksolidchurchdemo.com/GetImage.ashx?guid=923329f4-819e-4eaa-8d96-9611624736e8"
       HeightRequest="{Rock:OnDeviceType Phone=300, Tablet=150}" />

When running on a phone, the image will have a height of 300 pixels. But on a tablet it will only have a height of 150 pixels. This might be useful if you are worried that the image might take up too much vertical space on a tablet under normal sizing circumstances.

            <Button Text="Go" />
            <Label Text="This feature requires a tablet." />

Here is a more interesting example. In this case we are replacing not just a property but an entire element. On tablet devices, they will see a button which they can tap. On every other device type they will see a label that informs them the feature only works on tablets.

Last updated

⚙️ Powered by Rock RMS