【问题标题】:New OnPlatform/OnIdiom XAML Extension - Usage for Margin Thickness新的 OnPlatform/OnIdiom XAML 扩展 - 用于边距厚度
【发布时间】:2019-03-25 15:08:32
【问题描述】:

在 Xamarin.Forms 3.2.0 中,Xamarin Forms 引入了新的新 OnPlatform/OnIdiom XAML 扩展

根据blog我们可以重写下面的代码,

<Button Text="Extensions" BackgroundColor="Black" TextColor="White">
<Button.HeightRequest>
     <OnPlatform x:TypeArguments="x:Double" Default="40">
        <On Platform="iOS" Value="60"/>
        <On Platform="Android" Value="80"/>
    </OnPlatform>
</Button.HeightRequest>

使用新的扩展名。

<Button Text="Extensions" BackgroundColor="Black" TextColor="White" 
    HeightRequest="{OnPlatform iOS=60, Android=80, Default=40}"/>

我的疑问是如何将相同的 OnIdiom XAML 扩展 用于 Margin / Thickness。

【问题讨论】:

标签: xaml xamarin.forms


【解决方案1】:

你应该可以这样做:&lt;Button Margin="{OnPlatform Android='10,5,10,0', iOS='10,20,10,0'}" /&gt;

看你更喜欢哪种语法!

【讨论】:

    猜你喜欢
    • 2021-08-10
    • 2011-11-06
    • 2017-02-27
    • 2011-11-09
    • 1970-01-01
    • 1970-01-01
    • 2013-11-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多