我有这段代码:
StackLayout stackLayout = new StackLayout {
Spacing = 0,
Children =
{
new Label
{
Text = "StackLayout",
HorizontalOptions = LayoutOptions.Start,
FontSize = 20
}
}
}
什么是在运行时更改空间属性和FontSize的最佳方法?
答案 0 :(得分:0)
您有对StackLayout的引用,因此要更改它的属性:
stackLayout.Spacing = 10;
要更改标签,您需要保留对它的引用:
Label label = new Label
{
Text = "StackLayout",
HorizontalOptions = LayoutOptions.Start,
FontSize = 20
};
StackLayout stackLayout = new StackLayout {
Spacing = 0,
Children =
{
label
}
}
然后你可以在运行时用
修改它label.FontSize = 30;