一次在应用程序xamarinforms中的所有按钮上设置填充

问题描述

我已经用xamarinforms设计了一个完整的应用程序,我想在应用程序中所有按钮的10个点上添加左右填充,有没有办法使用App.xaml或其他更改填充的方法仅适用于iOS平台的按钮?

解决方法

检查这两个ms文档:

  1. global style(您仍可以覆盖特定页面上的边距/填充)
  2. XAML markup for platform

这是您的App.xaml的示例:

<Application.Resources>
    <ResourceDictionary>
        <Style ApplyToDerivedTypes="True" TargetType="Button">
            <Setter Property="Margin" Value="{x:OnPlatform iOS='10,0',Android='0'}" />
        </Style>
    </ResourceDictionary>
</Application.Resources>