Reputation: 5236
Hi I have been trying to set icon in my application based on images in the app.xaml I have tried the following and they do not work:
usage in my page Icon="{StaticResource MyImageKey}">
<ImageSource x:Key="MyImageKey" >
<OnPlatform x:TypeArguments="ImageSource"
iOS="MyImage.jpg"
Android=""/>
</ImageSource>
<OnPlatform x:Key="MyImageKey"
x:TypeArguments="ImageSource">
<On Platform="iOS">"MyImage.png"</On>
<On Platform="Android">""</On>
</OnPlatform>
can you point me in the right direction?
thanks
Upvotes: 1
Views: 1040
Reputation: 2680
You need add style in App resource like below :
<Application.Resources>
<ResourceDictionary>
<OnPlatform x:Key="MyImageKey"
x:TypeArguments="ImageSource"
iOS="contact.png"
Android="contact.png"
WinPhone="contact.png" />
</ResourceDictionary>
</Application.Resources>
Now you can use like below :
<Image Source="{StaticResource MyImageKey}"
HorizontalOptions="Center"
VerticalOptions="Center" />
Upvotes: 1