2017-09-12 13 views
0

私はカスタムのユーザーコントロールを使用して、アプリケーションでFontAwesomeフォントを使用していて、正しく動作します。Xamarinフォーム - カスタムUserControlでResourceDictionaryスタイルを使用する

App.xamlのResourceDictionaryでStyleを使用してコントロールのスタイルを設定したいとします。スタイルを利用

enter image description here

ページは次のとおりです。

  <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> 

スタイルは、通常のラベルに正しく動作することに注意してください - 緑の矢印。

私はアプリケーションを実行すると、私は次のエラーを取得する:

enter image description here

だから私は問題はなスタイルでのTargetTypeである把握。

しかし、私が試してみました:

  • TargetTypeに= "ラベル">
  • TargetTypeに= "Label.FontFamily"
  • TargetTypeに= "のfontFamily">
  • TargetTypeに= "のUserControlを:FontAwesomeLabel ">
  • TargetTypeが=" のUserControl ">
  • TargetTypeに=" FontAwesomeLabel ">

同じ結果が表示されます。

ユーザーコントロールのコードは次のとおりです。 enter image description here

私は何をしないのですか?

ありがとうございます!

答えて

0

追加さ

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

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

約100バリエーションにTargetTypeに設定しようとしました。同じ問題。

また、設定者の入力ミススペースも修正しました。

関連する問題