您可以通过这种方式使用 OnPlatform 来根据平台显示/隐藏某些内容:
<StackLayout IsVisible="{OnPlatform iOS=true, Android=false}">
<Button Text="Annulla" FontSize="Small" TextColor="White" FontAttributes="Bold" BackgroundColor="Transparent" HorizontalOptions="Start" Command="{prism:GoBack UseModalNavigation=True}"/>
<Label Text="Comunicazione" TextColor="White" FontAttributes="Bold" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"/>
<Button Text="Salva" TextColor="White" FontAttributes="Bold" BackgroundColor="Transparent" HorizontalOptions="End" Command="{Binding SalvaComunicazioneCommand}"/>
<Button Text="Rimuovi" TextColor="White" FontAttributes="Bold" BackgroundColor="Transparent" HorizontalOptions="End" Command="{Binding RimuoviComunicazioneCommand}"/>
</StackLayout>
我认为即使在 Xamarin 生命周期中,这种语法也已经过时了。这应该是替代品:
<OnPlatform x:TypeArguments="View">
<On Platform="iOS">
<StackLayout BackgroundColor="{DynamicResource StandardColor}" Padding="15,5,15,3" Orientation="Horizontal" IsVisible="{Binding Modal}">
<Button Text="Annulla" FontSize="Small" TextColor="White" FontAttributes="Bold" BackgroundColor="Transparent" HorizontalOptions="Start" Command="{prism:GoBack UseModalNavigation=True}"/>
<Label Text="Comunicazione" TextColor="White" FontAttributes="Bold" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"/>
<Button Text="Salva" TextColor="White" FontAttributes="Bold" BackgroundColor="Transparent" HorizontalOptions="End" Command="{Binding SalvaComunicazioneCommand}"/>
<Button Text="Rimuovi" TextColor="White" FontAttributes="Bold" BackgroundColor="Transparent" HorizontalOptions="End" Command="{Binding RimuoviComunicazioneCommand}"/>
</StackLayout>
</On>
<On Platform="Android">
</On>
</OnPlatform>
在 Microsoft Learn 上了解更多相关信息。
请注意,您可能还想研究专门的
HorizontalStackLayout
或 VerticalStackLayout
。