Currently I can measure the impressive font icons on my page with tabs from XAML code as follows:
<ContentPage.IconImageSource>
<FontImageSource FontFamily="{StaticResource Solid }" Glyph="" ></FontImageSource>
</ContentPage.IconImageSource>
That way I can already put icons in my applications, but I want to do it from the codebehind because that tabbed page will have to be created from certain actions and I did it in the following way:
contenido.IconImageSource = new ContentPage().IconImageSource {
new FontImageSource().FontFamily = "\uf108";
};
but in the first "{" I get the error that says "I expected one ; "
Update
code App.xaml
<Application.Resources>
<ResourceDictionary>
<!--Global Styles-->
<Color x:Key="NavigationPrimary">#2196F3</Color>
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="{StaticResource NavigationPrimary}" />
<Setter Property="BarTextColor" Value="White" />
</Style>
<OnPlatform x:TypeArguments="x:String"
x:Key="Brands">
<On Platform="Android"
Value="BrandsRegular.otf#Regular" />
</OnPlatform>
<OnPlatform x:TypeArguments="x:String"
x:Key="Regular">
<On Platform="Android"
Value="FreeRegular.otf#Regular" />
</OnPlatform>
<OnPlatform x:TypeArguments="x:String"
x:Key="Solid">
<On Platform="Android"
Value="FreeSolid.otf#Regular" />
</OnPlatform>
</ResourceDictionary>
</Application.Resources>
Now with the magic of Kits, you can upload your own icons and use them right alongside official Font Awesome ones!
You don't need to create a new ContentPage, just create a FontImageSource
object and set the values accordingly then pass this object to the IconImageSource
of your contenido
Page.
Also, you will need to get the StaticResource from the App Resources Dictionary.
Something like this should work:
var solidFontFamily = Application.Current.Resources["Solid"] as OnPlatform<string>;
contenido.IconImageSource = new FontImageSource() { FontFamily = solidFontFamily, Glyph= "\uf108" };
Hope this helps.-
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With