Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Marc Bruins MarcBruins

🏠
Working from home
Block or report user

Report or block MarcBruins

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View viewmodel creation gist
#ViewModel Creation
In MvvmCross v3 - Hot Tuna - the default ViewModel location and construction was overhauled in order to provide 3 new features:
- constructor based Dependency Injection
- navigation using Typed navigation classes
- saving and reloading VM state for 'tombstoning'
These changes were breaking changes for existing v1 and vNext apps, but provide significant testability and usability advantages for MvvmCross developers.
@MarcBruins
MarcBruins / MonkeyCell.cs
Last active Oct 14, 2017
MonkeyTableviewcell
View MonkeyCell.cs
using System;
using Foundation;
using MvvmCross.Binding.BindingContext;
using MvvmCross.Binding.iOS.Views;
using UIKit;
namespace MonkeyList.Core.iOS
{
public partial class MonkeyCell : MvxTableViewCell
{
View MonkeysView.cs
using System;
using MonkeyList.Core.ViewModels;
using MvvmCross.Binding.BindingContext;
using MvvmCross.Binding.iOS.Views;
using MvvmCross.iOS.Views;
using UIKit;
namespace MonkeyList.Core.iOS
{
public partial class MonkeysView : MvxViewController<MonkeysViewModel>
View Monkey.cs
namespace MonkeyList.Core
{
public class Monkey
{
public string Name { get; set; }
public string Location { get; set; }
public string Details { get; set; }
public string Image { get; set; }
}
}
View MonkeysViewModel.cs
using MvvmCross.Core.ViewModels;
namespace MonkeyList.Core.ViewModels
{
public class MonkeysViewModel : MvxViewModel
{
public MvxObservableCollection<Monkey> Monkeys => new MvxObservableCollection<Monkey>();
public MonkeysViewModel()
{
View MonkeysView.cs
using Android.App;
using Android.OS;
using MvvmCross.Droid.Views;
namespace MonkeyList.Droid
{
[Activity]
public class MonkeysView : MvxActivity
{
protected override void OnCreate(Bundle bundle)
View MonkeyView.axml
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/darker_gray">
<MvxRecyclerView
android:id="@+id/my_recycler_view"
android:scrollbars="vertical"
View listitem_monkey.axml
<?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:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="2dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
View Setup.cs
namespace MonkeyList.Droid
{
public class Setup : MvxAndroidSetup
{
//Default stuff goes here
protected override IEnumerable<Assembly> AndroidViewAssemblies => new List<Assembly>(base.AndroidViewAssemblies)
{
typeof(MvvmCross.Droid.Support.V7.RecyclerView.MvxRecyclerView).Assembly
};
@MarcBruins
MarcBruins / AutoCompleteTextFieldSetup.cs
Last active Oct 14, 2017
AutoCompleteTextField setup
View AutoCompleteTextFieldSetup.cs
AutoCompleteTextField.Setup(this, new List<string>() { "customizable", "xamarin", "autocomplete", "ios" });
You can’t perform that action at this time.