Roubachof
Roubachof

Reputation: 3401

mvvmcross binding on switch fails on release

I have a weird bug in my MVVMCross app.

Considering the following scenario:

<Switch
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:focusable="false"
    android:clickable="false"
    android:layout_alignParentRight="true"
    android:id="@+id/activatedSwitch"
    local:MvxBind="Checked IsActive" />

When I run the app in Debug mode, all is ok.

But when I run it in Release, the binding to the Checked property failed with the following error:

E/MvxBind (11670): 12,70 View type not found - Switch

Upvotes: 8

Views: 2061

Answers (2)

Anees Deen
Anees Deen

Reputation: 1413

The latest version of MVVMCross has this issue addressed. The below code is only enough.
Note:- MvvmCross 7.0. I am using. But I suspect this could be addressed in before releases.

local:MvxBind="Checked IsActive"

Upvotes: 0

Kiliman
Kiliman

Reputation: 20312

Since MvvmCross uses reflection to perform databinding, the linker is not seeing the Checked property and is not including it in your binary. There is a file name LinkerPleaseInclude.cs that you can edit to add a reference to this property.

Something like:

public void Include(Switch @switch)
{
    @switch.CheckedChange += (sender, args) => @switch.Checked = [email protected];
}

Upvotes: 14

Related Questions