`namespace AAAApp.UserControls
{
public class FontAwesomeLabel : Label
{
public static readonly string FontAwesomeName = "FontAwesome";
//Parameterless constructor for XAML
public FontAwesomeLabel()
{
FontFamily = FontAwesomeName;
}
public FontAwesomeLabel(string fontAwesomeLabel = null)
{
FontFamily = FontAwesomeName;
Text = fontAwesomeLabel;
}
}
// https://github.com/neilkennedy/FontAwesome.Xamarin/blob/master/FontAwesome.Xamarin/FontAwesome.cs
// For a huge list of icon codes
public static class Icon
{
public static readonly string FAGlass = "\uf000";
public static readonly string FAMusic = "\uf001";`
Posts
When using this syntax:
<Style TargetType="{local:CustomControl}"> <Setter Property="Padding" Value="20,40,20,0" /> </Style>
It seems to instantiate the custom control because the constructor is invoked, but throw an InvalidCastException.
Any ideas?
I know this is an older thread, but in case you haven't found the answer.
First reference the namespace properly in the Application root (IE: xmlns:ctrls="clr-namespace:ProjectName.Folder")
Then use the below:
Hi Stacy,
I have the same issue and tried your solution:
``
<Application.Resources>
The Control:
`namespace AAAApp.UserControls
{
public class FontAwesomeLabel : Label
{
public static readonly string FontAwesomeName = "FontAwesome";
But is still breaks. Any Suggestions?
@RicardoMedina : Did you find solution to this ? I'm also facing the same issue.
Sorry Sagar, I know I did, but don't remember how. Haven't done a mobile app on xamarin for a while. But this may help: https://stackoverflow.com/questions/46182833/xamarin-form-utilizing-resourcedictionary-style-with-custom-usercontrol