Can WidthRequest be converted or overwritten depending on Device type(Tablet, phone or Desktop)?

Viewed 29

My IOS Application utilize WidthRequest all over my XAML code and would like to know if there is a faster way on overwriting or converting each fixed WidthRequest value depending on the Device?

The easiest way is to put OnIdiom in every code but will take more time to code. Example I need to do the example code below 200+ times which will take a lot of time

From :

<Button  WidthRequest="500"
        Text="CLOSE"
        FontSize="Large"
        Command="{Binding CancelCommand}"
        TextColor="White"/>

To :

<Button Text="CLOSE"
        FontSize="Large"
        Command="{Binding CancelCommand}"
        TextColor="White" >
    <Button.WidthRequest>
        <OnIdiom x:TypeArguments="x:Double">
            <OnIdiom.Phone>250</OnIdiom.Phone>
            <OnIdiom.Tablet>500</OnIdiom.Tablet>
        </OnIdiom>
</Button.WidthRequest> 
0 Answers
Related