我尝试绑定到 ImageView Alpha 属性,我创建了一个转换器来将此设置为布尔值。但我不认为设定值。
这是我的转换器
public class BooleanToOpacity : MvxValueConverter<bool,int>
{
protected override int Convert(bool value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var boolean = value as bool?;
if (boolean.Value == true)
{
return 1;
}
else
{
return 127;
}
}
protected override bool ConvertBack(int value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value > 127)
{
return true;
}
else
{
return false;
}
}
}
我使用整数值,因为 Alpha 值是 0 到 255。
这是我绑定价值的路线。
local:MvxBind="alpha TwitterPost, Converter=BooleanToOpacity" />
Mvx 跟踪我这个
MvxBind:Warning: 11.56 Failed to create target binding for binding alpha for TwitterPost
[0:] MvxBind:Warning: 11.56 Failed to create target binding for binding alpha for TwitterPost
10-21 15:54:22.280 I/mono-stdout(12096): MvxBind:Warning: 11.56 Failed to create target binding for binding alpha for TwitterPost
任何想法?
提前致谢。