【发布时间】:2016-06-23 16:52:26
【问题描述】:
我正在使用 MvvmCross 4 并尝试绑定到 axml 中 ListView 元素的 backgroundColor。现在的问题是颜色取决于我模型中的 2 个属性:bool IsSpecialCategory 和 bool IsNsfw - 每个组合都应该得到另一种颜色。
在 iOS 中,使用 fluent 语法,在转换器中使用整个模型是没有问题的,但是在使用 axml 的 Android 中这可能吗?最简单的解决方案是在项目布局中为转换器提供整个模型,而不仅仅是一个属性:
<LinearLayout [...]
local:MvxBind="backgroundColor ItemBackgroundColorConverter(theWholeModelNotJustAProperty)">
【问题讨论】:
-
local:MvxBind="BackgroundColor CellChannelItemBackgroundColorConverter()" ...就足够了,你就得到了整个模型。有时真的很容易;)
标签: android binding xamarin converter mvvmcross