【发布时间】:2018-05-07 18:44:09
【问题描述】:
我正在尝试根据正在运行的设备更改条目的背景。 我尝试根据以下信息进行操作:https://developer.xamarin.com/guides/xamarin-forms/xaml/passing-arguments/
并得到了这个:
<Entry TextColor="White"
x:Name="entryTop"
HeightRequest="40"
WidthRequest="150"
RelativeLayout.XConstraint = "{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=.48,
Constant=10}"
RelativeLayout.YConstraint = "{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=0,
Constant=5}" >
<Entry.BackgroundColor>
<OnPlatform x:TypeArguments="x:String">
<On Platform="Android" Value="Transparent" />
<On Platform="iOS" Value="white" />
</OnPlatform>
</Entry.BackgroundColor>
</Entry>
当我尝试构建我的项目时,我收到此错误:没有为 BackgroundColor 找到属性、可绑定属性或事件,或者值和属性之间的类型不匹配。
我尝试了颜色工厂方法和几个TypeArguments,但似乎找不到正确的方法。
【问题讨论】:
-
BackgroundColor不是字符串,它的类型是Color。 -
我已经尝试过使用颜色类型,但它不起作用。还有 Color.FromHex 和我之前提到的工厂方法,如我发布的链接中所示。
标签: c# xaml xamarin.ios xamarin.forms xamarin.android