I am following this tutorial and the way they used mvxbind for thier Home, Info and third fragments to their respective viewmodels. I tried to do exactly same for my other fragment but I don't know what I am doing wrong but it MvxBind is not working. Here is the code for my viewmodel and layout.
SomeViewModel.cs
public class SomeViewModel : BaseViewModel
{
public SomeViewModel()
{
}
private MvxCommand someViewModelCommand;
public MvxCommand SomeViewModelCommand
{
get
{
someViewModelCommand = someViewModelCommand ?? new MvxCommand(DoSomeViewModel);
return someViewModelCommand;
}
}
private void DosomeViewModel()
{
ShowViewModel<FirstViewModel>();
}
}
FirstViewModel.cs
public class FirstViewModel : BaseViewModel
{
public FirstViewModel()
{
First = "Some Info for you...";
}
public string First
{
get;
private set;
}
}
Now I have layout something like this: SomeLayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>
<Button
android:id="@+id/someButton"
android:text="Do Something"
android:layout_width="match_parent"
android:layout_height="wrap_content"
local:MvxBind="Click SomeViewModelCommand" />
</LinearLayout>
Updated
SomeFragment.cs
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
// Use this to return your custom view for this Fragment
// return inflater.Inflate(Resource.Layout.YourFragment, container, false);
ShowHamburgerMenu = true;
oldTitle = ((MainActivity)Activity).Title;
((MainActivity)Activity).Title = "Track Packages";
//var view = base.OnCreateView(inflater, container, savedInstanceState);
var ignored = base.OnCreateView(inflater, container, savedInstanceState);
var view = this.BindingInflate(Resource.Layout.fragment_trackpackage, container, false);
return view;
}