View:
<android.support.v7.widget.SearchView
android:id="@+id/searchView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
local:MvxBind="Query SearchString" />
ViewModel:
private string _searchString;
public string SearchString
{
get { return _searchString; }
set
{
_searchString = value;
RaisePropertyChanged(() => SearchString);
}
}
Query should bind correctly.
Only the getter is working when the viewmodel loads. The setter doesn't.
I/MvxBind(7360): 15,87 Failed to create target binding for binding Query for SearchString
Version: 5.0.1
Platform:
Query property does not have a Setter. The target binding needs SetImplementation, to invoke SetQuery().
Just played with the Target Binding a bit. It should work From the View -> ViewModel. So if you edit the text inside of the SearchView, your ViewModel should be updated. However, as is now, if you edit the SearchString in the ViewModel, it won't be reflected in the SearchView. Will prepare a fix for that now.
As for AppCompat SearchView, we have TargetBindings for that too. They are in MvvmCross.Droid.Support.V7.AppCompat. Make sure you replace MvxAndroidSetup with MvxAppCompatSetup instead.
Confirmed, it is now working after replacing MvxAndroidSetup with MvxAppCompatSetup. Thanks a lot! :)