I have a TextView
bound with Enabled, Clickable
and Click. When the activity
is loaded, Enabled & Clickable
were bound to false value but the TextView
cannot be disabled & still be clickable. After changed the bound value to true & then false, the TextView
is disabled.
I found that the issue was related to binding the Click event. Once Click is bound, the mentioned issue occurs. Without binding the Click event, it works as expected.
In the following sample code, the first 2 TextViews
are ok. The last one with binding Click does not work.
BTW, I have this issue with TextInputEditText
instead. I found the situation applies to TextView
as well so I use TextView
for illustration.
<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;
}
}
Any idea how to fix?
Thanks
As Stuart said, there are some interaction between
ICommand.CanExecute
and theEnabled
property. Switching the binding to :Effect.