如何在Platform标记的工具栏项上绑定图像图标

问题描述 投票:0回答:1

这是我的代码:

<ToolbarItem 
    Icon="{OnPlatform iOS='iconscalendarplus64.png', Android='iconscalendarplus64.png'}" 
    Priority="0"
    Order="Primary" 
    Command="{Binding PrikaziCommand}"

我尝试为Android ON Platform绑定图像。但是不起作用。

xamarin.forms android-toolbar
1个回答
0
投票

最简单的方法是:

                <ToolbarItem.Icon>
                <OnPlatform x:TypeArguments="ImageSource">
                    <OnPlatform.iOS><FileImageSource File=""icon.png""/></OnPlatform.iOS>
                    <OnPlatform.Android><FileImageSource File=""icon.png""/></OnPlatform.Android>
                    <OnPlatform.WinPhone><FileImageSource File=""Images/icon.png""/></OnPlatform.WinPhone>
                </OnPlatform>
                </ToolbarItem.Icon>

好是您可以在这里基于平台使用所有四种类型的ImageSource。

祝您好运,如有疑问,请随时回来

© www.soinside.com 2019 - 2024. All rights reserved.