1

I have a custom User Control as to utilized FontAwesome fonts on the app, and it works correctly.

I want to style the control with Style in the ResourceDictionary in App.xaml.

enter image description here

The page utilizing the style is:

            <StackLayout x:Name="TopStack">
            <Grid VerticalOptions="FillAndExpand" BackgroundColor="#012c50" HeightRequest="200">
                <Image Source="{local:ImageResource AAAApp.Images.navbartop.png}" Aspect="AspectFill" />
                <userControls:FontAwesomeLabel Text="{x:Static userControls:Icon.FAUserCircle}" Style="{StaticResource SideMenuNameIcon}" />
                <userControls:FontAwesomeLabel Text="{x:Static userControls:Icon.FAChevronRight}" />
                <Label Text="Name Here" Style="{StaticResource SideMenuName}" />
                <Label Text="1234567891231" Style="{StaticResource SideMenuAccount}" />
            </Grid>
        </StackLayout>

Please notice that Styles work correctly on the regular labels - green arrow.

When I run the application, I get the following error:

enter image description here

So I figure out the issue is with the TargetType in the style.

However, I have tried:

  • TargetType="Label">
  • TargetType="Label.FontFamily"
  • TargetType="FontFamily">
  • TargetType="userControls:FontAwesomeLabel">
  • TargetType="userControls">
  • TargetType="FontAwesomeLabel">

With the same results.

The UserControl code is: enter image description here

What am I missing?

Thanks!

Diomedes
  • 634
  • 11
  • 24

1 Answers1

1

Added

Added xmlns:ctrls="clr-namespace:AAAApp.UserControls" to app.xaml and Change

in App.xaml and tried setting TargetType to

TargetType="{x:Type ctrls:FontAwesomeLabel}"

and about 100 variations. Same issue.

Also fix typo - blank space - in setter.

Diomedes
  • 634
  • 11
  • 24