MvvmCross Android 绑定已启用不适用于 Click
MvvmCross Android binding Enabled not work with Click
我有一个 TextView
绑定了 Enabled,Clickable
和 Click。加载 activity
时,已启用和 Clickable
被绑定为 false 值,但 TextView
无法禁用且仍可点击。将绑定值更改为 true 和 false 后,TextView
被禁用。
我发现问题与绑定 Click 事件有关。一旦绑定Click,就会出现上述问题。在不绑定 Click 事件的情况下,它会按预期工作。
下面的示例代码中,前2个TextViews
就可以了。最后一个带绑定点击不起作用
顺便说一句,我遇到的问题是 TextInputEditText
。我发现这种情况也适用于 TextView
,所以我使用 TextView
来说明。
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="test textview can be disabled at load"
style="@style/EntryTextStyle"
local:MvxBind=" Enabled RouteMarker.ArrivalNotice" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="test textview with no click command, can be disabled at load"
style="@style/EntryTextStyle"
local:MvxBind=" Enabled RouteMarker.ArrivalNotice;
Clickable RouteMarker.ArrivalNotice" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="test textview with click command cannot be disabled at load"
style="@style/EntryTextStyle"
local:MvxBind=" Enabled RouteMarker.ArrivalNotice;
Clickable RouteMarker.ArrivalNotice;
Click DoSomethingCommand" />
private IMvxAsyncCommand _doSomethingCommand;
public IMvxAsyncCommand DoSomethingCommand
{
get
{
_doSomethingCommand = _doSomethingCommand ?? new MvxAsyncCommand(async () =>
{
await Task.Delay(10);
});
return _doSomethingCommand;
}
}
知道如何解决吗?
谢谢
正如Stuart所说,ICommand.CanExecute
和Enabled
属性之间有一些相互作用。将绑定切换为:
local:MvxBind="Click DoSomethingCommand;Enabled RouteMarker.ArrivalNotice;Clickable RouteMarker.ArrivalNotice;"
Effect.
我有一个 TextView
绑定了 Enabled,Clickable
和 Click。加载 activity
时,已启用和 Clickable
被绑定为 false 值,但 TextView
无法禁用且仍可点击。将绑定值更改为 true 和 false 后,TextView
被禁用。
我发现问题与绑定 Click 事件有关。一旦绑定Click,就会出现上述问题。在不绑定 Click 事件的情况下,它会按预期工作。
下面的示例代码中,前2个TextViews
就可以了。最后一个带绑定点击不起作用
顺便说一句,我遇到的问题是 TextInputEditText
。我发现这种情况也适用于 TextView
,所以我使用 TextView
来说明。
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="test textview can be disabled at load"
style="@style/EntryTextStyle"
local:MvxBind=" Enabled RouteMarker.ArrivalNotice" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="test textview with no click command, can be disabled at load"
style="@style/EntryTextStyle"
local:MvxBind=" Enabled RouteMarker.ArrivalNotice;
Clickable RouteMarker.ArrivalNotice" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="test textview with click command cannot be disabled at load"
style="@style/EntryTextStyle"
local:MvxBind=" Enabled RouteMarker.ArrivalNotice;
Clickable RouteMarker.ArrivalNotice;
Click DoSomethingCommand" />
private IMvxAsyncCommand _doSomethingCommand;
public IMvxAsyncCommand DoSomethingCommand
{
get
{
_doSomethingCommand = _doSomethingCommand ?? new MvxAsyncCommand(async () =>
{
await Task.Delay(10);
});
return _doSomethingCommand;
}
}
知道如何解决吗?
谢谢
正如Stuart所说,ICommand.CanExecute
和Enabled
属性之间有一些相互作用。将绑定切换为:
local:MvxBind="Click DoSomethingCommand;Enabled RouteMarker.ArrivalNotice;Clickable RouteMarker.ArrivalNotice;"
Effect.