Issue
I am programming with Xamarin.Forms. I would like know how to only set the height request for a single platform, using OnPlatform
in XAML? I want to keep the default value of -1
if the platform is not referred.
I currently have the following code:
<ListView.HeightRequest>
<OnPlatform x:TypeArguments="x:Double">
<On Platform="WPF" Value="153" />
<On Platform="Android" Value="-1" />
<On Platform="iOS" Value="-1" />
<On Platform="UWP" Value="-1" />
</OnPlatform>
</ListView.HeightRequest>
I wish I only had to write something like:
<ListView.HeightRequest>
<OnPlatform x:TypeArguments="x:Double">
<On Platform="WPF" Value="153" />
</OnPlatform>
</ListView.HeightRequest>
This doesn't work, is it possible?
Solution
You can write the platforms with same value in one line:
<ListView.HeightRequest>
<OnPlatform x:TypeArguments="x:Double">
<On Platform="WPF" Value="153" />
<On Platform="Android,iOS,UWP" Value="-1" />
</OnPlatform>
</ListView.HeightRequest>
Refer: Providing platform-specific values
Answered By - nevermore
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.