Mvvmcross Android TextInputEditText Binding Enabled

时间:2017-12-04 12:23:46

标签: xamarin.android mvvmcross

我有一个Switch和一个TextInputEditText。两者都启用了'绑定到viewmodel中的相同字段。

加载活动时,绑定字段设置为false。 Switch按预期禁用。但是,TextInputEditText已启用。 ' Clickable'有同样的问题。文本绑定成功。

将绑定字段更改为true然后将其更改为false后,TextInputEditText启用&可点击的工作正常。它似乎只有在最初加载时才会发生。

            <android.support.v7.widget.SwitchCompat
                style="@style/EntryTextStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                local:MvxLang="Text LabelDeferArrivalNotice"
                local:MvxBind="Checked RouteMarker.DeferArrivalNotice; Enabled RouteMarker.ArrivalNotice" />
            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <android.support.design.widget.TextInputEditText
                    android:id="@+id/edittext_route_marker_EffectiveFromDateTime"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:singleLine="true"
                    android:editable="false"
                    android:focusableInTouchMode="false"
                    style="@style/EntryTextStyle"
                    local:MvxLang="Hint LabelEffectiveFromTime"
                    local:MvxBind="Text DateTimeToString(RouteMarker.EffectiveFromDateTime); 
                                   Enabled RouteMarker.ArrivalNotice;
                                   Clickable RouteMarker.ArrivalNotice;
                                   Click PromptDeferTimeCommand" />

我与TextInputEditText有什么特别之处吗?

由于

1 个答案:

答案 0 :(得分:0)

这是MvvmCross的问题,正如Stuart所说,ICommand.CanExecuteEnabled属性之间存在一些互动。将绑定切换为:

local:MvxBind="Click PromptDeferTimeCommand;Enabled RouteMarker.ArrivalNotice;Clickable RouteMarker.ArrivalNotice;"

希望能帮助那些搜索过这个问题的人。