Xamarin 使用值转换器在mvvm交叉中分配选择器(可绘制)的正确方法是什么
我有一个观点Xamarin 使用值转换器在mvvm交叉中分配选择器(可绘制)的正确方法是什么,xamarin,xamarin.android,mvvmcross,Xamarin,Xamarin.android,Mvvmcross,我有一个观点 <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/sel_fragfinder_toolbar_selection_selected" local:MvxBind="Drawable DiscoverYourScent
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/sel_fragfinder_toolbar_selection_selected"
local:MvxBind="Drawable DiscoverYourScent;Converter=ButtonState"
android:layout_weight="1"
android:textColor="@android:color/white"
android:textAllCaps="false"
android:layout_marginRight="10dp"
android:padding="10dp"
android:text="Discover your scent" />
我正在设置DiscoverYourScent=true代码>
目前尚未设置。。。。使用值转换器在mvvm cross中指定选择器(可绘制)的正确方法是什么您的绑定表达式是:
Drawable DiscoverYourScent;Converter=ButtonState
这里的问题是您有一个源-目标分配和转换器语句之间的代码>分号
它必须是,
逗号
Drawable DiscoverYourScent, Converter=ButtonState
或者,你也可以写:
Drawable ButtonState(DiscoverYourScent)
如果其余绑定正确,您应该看到您的ValueConverter
现在被点击。我相信您希望绑定到后台
作为源代码,而不是可绘制
。后者似乎不是按钮上的公共属性
正如Kiliman在对OP的评论中指出的那样,您也可以试试运气设置Selected
属性,而不要更改您的可绘制属性。只需确保您使用的可绘制文件具有正确的状态。您是否尝试绑定到选定的文件,而不是尝试绑定到Drawable
?然后Android将选择适当的状态选择器。顺便说一句:Mvx目前只支持绑定到从ImageVIew
派生的视图中的可绘制视图。看见
Drawable DiscoverYourScent, Converter=ButtonState
Drawable ButtonState(DiscoverYourScent)