【发布时间】:2017-09-12 18:02:17
【问题描述】:
我有一个自定义用户控件,用于在应用程序上使用 FontAwesome 字体,它可以正常工作。
我想在 App.xaml 的 ResourceDictionary 中使用 Style 设置控件的样式。
使用该样式的页面是:
<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>
请注意,样式在常规标签上正常工作 - 绿色箭头。
当我运行应用程序时,我收到以下错误:
所以我发现问题在于样式中的 TargetType。
不过,我试过了:
- TargetType="标签">
- TargetType="Label.FontFamily"
- TargetType="FontFamily">
- TargetType="userControls:FontAwesomeLabel">
- TargetType="userControls">
- TargetType="FontAwesomeLabel">
结果相同。
我错过了什么?
谢谢!
【问题讨论】:
标签: c# mobile xamarin.forms styles custom-controls