我想设置自定义类字体大小。你现在我该怎么办?
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 :(得分: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
}
}