2017-12-04 14 views
0

カスタムクラスのフォントサイズを設定したい場合があります。私はこれをどうすればできるのですか?カスタムクラスのフォントサイズを設定するXamarinフォーム

CustomButtonクラス

public static readonly BindableProperty PaddingProperty = 
     BindableProperty.Create(
      nameof(Padding), 
      typeof(Thickness), 
      typeof(CustomButton), 
      new Thickness(0, 0, 0, 0)); 

    public static readonly BindableProperty TypeProperty = 
     BindableProperty.Create(
      nameof(Type), 
      typeof(TypeEnum), 
      typeof(CustomButton), 
      TypeEnum.Blue 
      ); 

public Thickness Padding 
    { 
     get { return (Thickness)GetValue(PaddingProperty); } 
     set { SetValue(PaddingProperty, value); } 
    } 

答えて

0

あなたの "カスタムボタンは" Xamarin.Forms.Buttonから継承する場合は、あなただけの、その "のFontSize" プロパティを設定することができます。

public class CustomButton : Xamarin.Forms.Button //Inheriting from Xamarin.Forms.Button! 
    { 
     public static readonly BindableProperty PaddingProperty = 
     BindableProperty.Create(
      nameof(Padding), 
      typeof(Thickness), 
      typeof(CustomButton), 
      new Thickness(0, 0, 0, 0)); 

     public static readonly BindableProperty TypeProperty = 
      BindableProperty.Create(
       nameof(Type), 
       typeof(TypeEnum), 
       typeof(CustomButton), 
       TypeEnum.Blue 
       ); 

     public Thickness Padding 
     { 
      get { return (Thickness)GetValue(PaddingProperty); } 
      set { SetValue(PaddingProperty, value); } 
     } 

     public CustomButton() 
     { 
      FontSize = 123; //FontSize property on Xamarin.Forms.Button 
     } 
    } 
関連する問題