【发布时间】:2018-10-04 14:38:41
【问题描述】:
我有这个代码:
<StackLayout Padding="20"
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand"
BackgroundColor="Black" >
<Grid BackgroundColor="Black" >
在许多不同的地方重复同样的事情,并且都将 BackgroundColor 指定为相同。
有没有一种方法可以让我在一个地方指定这个color,然后以某种方式绑定或引用它?比如:
<Grid BackgroundColor="{ TheBackgroundColor }" >
然后在一个文件中设置 TheBackgroundColor 并在全局范围内使用。
【问题讨论】:
-
<Style TargetType="StackLayout"> <Setter Property="BackgroundColor" Value="#ff0000" /> </Style> -
我正在寻找能够保存用于颜色的常量的东西,而不仅仅是如何设置 StackLayout 背景颜色。
标签: xamarin xamarin.forms