question

JassimAlRahma-9056 avatar image
0 Votes"
JassimAlRahma-9056 asked KyleWang-MSFT answered

x:Int16's OnIdiom

Hi,

I have this Int16 in my App.xaml

 <x:Int16 x:Key="HeaderHeight">50</x:Int16>

I want to know how can I use OnIdiom with it to have it 50 for Phone and 8- for Tablet?


Thanks,
Jassim


dotnet-xamarinforms
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

KyleWang-MSFT avatar image
0 Votes"
KyleWang-MSFT answered

Hi JassimAlRahma-9056,

Welcome to our Microsoft Q&A platform!

Xamarin does not provide such markup. A workaround is that you can define the HeaderHeight in App.xaml for both phone and tablet.

Then use the "HeaderHeight" via StaticResource.

Here is a simple demo.

App.xaml

 <Application.Resources>
     <x:Double x:Key="HeightOnPhone">100</x:Double>
     <x:Double x:Key="HeightOnTablet">50</x:Double>
 </Application.Resources>

MainPage.xaml

 <BoxView Color="Blue"
         WidthRequest="200"
         HeightRequest="{OnIdiom 200, Phone={StaticResource HeightOnPhone}, Tablet={StaticResource HeightOnTablet}}"
         HorizontalOptions="Center" />

Regards,
Kyle


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.