C# Xamarin形成图标

C# Xamarin形成图标,c#,xaml,xamarin,xamarin.forms,glyphicons,C#,Xaml,Xamarin,Xamarin.forms,Glyphicons,我想知道如何在Xamarin表单应用程序中实现图标。我想使用象形文字图标或字体。但是,我不知道如何在我的xaml/c页面中实现它 理想情况下,我的目标如下: 如果有人能提供代码来显示像搜索栏或三行这样的图标,那就太好了。我可以把它格式化成好看的。我一直在努力想如何真正把图标拉进去 最简单的方法可能是使用 从Visual Studio或Xamarin Studio安装以下软件包: Xam.Plugin.Iconize Xam.Plugin.Iconize.font Xam.FormsPlugi

我想知道如何在Xamarin表单应用程序中实现图标。我想使用象形文字图标或字体。但是,我不知道如何在我的xaml/c页面中实现它

理想情况下,我的目标如下:


如果有人能提供代码来显示像搜索栏或三行这样的图标,那就太好了。我可以把它格式化成好看的。我一直在努力想如何真正把图标拉进去

最简单的方法可能是使用

从Visual Studio或Xamarin Studio安装以下软件包:

  • Xam.Plugin.Iconize
  • Xam.Plugin.Iconize.font
  • Xam.FormsPlugin.Iconize
注意:如果需要,您可以安装Xam.Plugin.Iconize.Material和其他许多类似的工具

在Android项目中,MainActivity类的OnCreate()方法add

FormsPlugin.Iconize.Droid.IconControls.Init(Resource.Id.toolbar);
Plugin.Iconize.Iconize.With(new Plugin.Iconize.Fonts.FontAwesomeModule());
在iOS项目的AppDelegate类FinishedLaunching()方法中,添加类似的行

FormsPlugin.Iconize.iOS.IconControls.Init();
Plugin.Iconize.Iconize.With(new Plugin.Iconize.Fonts.FontAwesomeModule())
另外,在iOS项目中,info.plist添加

<key>UIAppFonts</key>
<array>     
    <string>iconize-fontawesome.ttf</string>
</array>    
UIAppFonts
iconize-fontawesome.ttf
现在,在您的XAML中,您有工具栏,在标记中,添加

<ContentPage ...
xmlns:iconize="clr-namespace:FormsPlugin.Iconize;assembly=FormsPlugin.Iconize" ...
>


看看Xamarin表单的新版本,解决方案已经制定!我把邮件寄了进来

但这就对了。以下代码可以正常工作:

<Button  Text="Pesquisar">
    <Button.ImageSource>
         <FontImageSource Glyph="&#xf002;" FontFamily="{StaticResource FontIcon}"/>
    </Button.ImageSource>
</Button>

这也是:

<ContentPage.ToolbarItems>
    <ToolbarItem>
        <ToolbarItem.IconImageSource>
             <FontImageSource Glyph="&#xf002;" FontFamily="{StaticResource FontIcon}"/>
        </ToolbarItem.IconImageSource>
    </ToolbarItem>
</ContentPage.ToolbarItems>


Google提供了一些支持这一点的软件包。你试过先搜索吗?是的,我看到的所有东西都需要自定义渲染和我无法掌握的技术。Iconize似乎不适用于windows手机。你能提供适用于iOS、Android和UWP的软件包的名称吗?@Connormeks你能看到我的答案吗,这是我几年前第一次实现它的方式,非常好而且简单,您不需要成为Xamarin专家。对于Xamarin表单中的自定义字体,您可以使用它,您可以在此处使用派生的Unicodes:这对Windows(UWP)有效吗?我需要为这些文件做些什么吗?这对Windows有效吗?或者这是Android/iOS特定的?不确定Windows。在UWP中尝试了这一点,但遗憾的是,它对commandbar图标不起作用。我正在可视化图标,但当我单击它时,它什么也不起作用。在Iconlabel中,它工作正常。iOS的工具栏项也可以
<ContentPage.ToolbarItems>
    <ToolbarItem>
        <ToolbarItem.IconImageSource>
             <FontImageSource Glyph="&#xf002;" FontFamily="{StaticResource FontIcon}"/>
        </ToolbarItem.IconImageSource>
    </ToolbarItem>
</ContentPage.ToolbarItems>