Reputation: 17422
I have Image
control in xaml, how can I give BackgroundColor
only for iOS
from xaml only
<Image BackgroundColor="Green" Source="bell.png" Grid.Row="0" Grid.Column="0"
HorizontalOptions="End" VerticalOptions="Center" >
</Image>
Upvotes: 0
Views: 46
Reputation: 2119
In your resource dictionary, add this:
<OnPlatform x:Key="MyBackgroundColor" x:TypeArguments="Color">
<On Platform="iOS">Green</On>
<On Platform="Android">Transparent</On>
<On Platform="Windows">Transparent</On>
</OnPlatform>
Then, use the resource in your image:
<Image
BackgroundColor="{StaticResource MyBackgroundColor}"
... />
Upvotes: 1
Reputation: 496
You can add inline code in xaml
<Image BackgroundColor="{ x:OnPlatform iOS='Green', Default='White'}">
</Image>
Upvotes: 2