Giter VIP home page Giter VIP logo

mvvmcross-controlsnavigation's Introduction

##MvvmCross - Controls Navigation Plugin

MvvmCross plugin that allows placing multiple ViewModels in the same View as Controls, creating composite views. ##Features

  1. Create composite views with multiple ViewModels asociated to Controls.
  2. Use the same ViewModels for a mobile and tablet Apps. It modifies the ShowViewModel behaviour, allowing you to show Controls, not just change Views.
  3. Implemented for iPad, Windows Store, Android Tablet Apps and Wpf applications.

##Sample

Windows Phone Default MVVMCross Navigation

Windows Store Controls Navigation

##Adding to your project

  1. Add it from NuGet: https://www.nuget.org/packages/MupApps.MvvmCross.Plugins.ControlsNavigation

  2. Override the CreateViewPresenter method on your Setup.cs file for each platform.

    Windows Store:

    protected override IMvxStoreViewPresenter CreateViewPresenter(Frame rootFrame)
    {
        var viewPresenter = base.CreateViewPresenter(rootFrame);
        return new MvxStoreControlPresenter(viewPresenter);
    }
    

    Droid:

    protected override IMvxAndroidViewPresenter CreateViewPresenter()
    {
        var viewPresenter = base.CreateViewPresenter();
        return new MvxAndroidControlPresenter(viewPresenter);
    }
    

    Touch:

    protected override IMvxTouchViewPresenter CreatePresenter()
    {
        var viewPresenter = base.CreatePresenter();
        return new MvxTouchControlPresenter(viewPresenter);
    }
    

    Wpf:

    private readonly Dispatcher _uiThreadDispatcher;
    private readonly IMvxWpfViewPresenter _presenter;
    
    public Setup(Dispatcher dispatcher, IMvxWpfViewPresenter presenter)
        : base(dispatcher, presenter)
    {
        _uiThreadDispatcher = dispatcher;
        _presenter = presenter;
    }
    
    protected override IMvxViewDispatcher CreateViewDispatcher()
    {
        var controlPresenter = new MvxWpfControlPresenter(_presenter);
       
        return new MvxWpfViewDispatcher(_uiThreadDispatcher, controlPresenter);
    }
    
  3. Create a /Controls folder

  4. Inherit your controls from MvxStoreControl, MvxAndroidControl or MvxTouchControl with the same name of the ViewModel but ending in Control (Ex: SecondViewModel -> SecondControl)

  5. Add the user control to one of your Views that is already binded with a ViewModel (Ex: FirstView)

The control will be hidden until ShowViewModel has been called. You could change that behaviour setting the property EmptyControlBehaviour (None, Hidden, Disabled)

Windows Store (on your View xaml):

```
xmlns:controls="using:YourNamespace.Controls"

...

<controls:SecondControl />
```

Droid (on your View axml):

```
<YourNamespace.Controls.SecondControl
    android:layout_height="fill_parent"
    android:layout_width="0dp"
    android:layout_weight="1" />
```

Touch:

a. Add a UIView to your nib View file from XCode and position it, or add it programmatically 
	to your MvxViewController

b. Ensure that your UIViewController for your control inherits from MxvTouchControl

c. Add your control to your View

```
public override void ViewDidLoad ()
{
	base.ViewDidLoad ();

	var secondControl = new SecondControl();
    AddChildViewController(secondControl);
    YourUIView.AddSubview(secondControl.View);

	...
}
```

Wpf (on your View xaml):

```
xmlns:controls="clr-namespace:YourNamespace.Controls"

...

<controls:SecondControl />
```

mvvmcross-controlsnavigation's People

Contributors

christianruiz avatar

Watchers

Javier Fernández Rodríguez avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.