##MvvmCross - Controls Navigation Plugin
MvvmCross plugin that allows placing multiple ViewModels in the same View as Controls, creating composite views. ##Features
- Create composite views with multiple ViewModels asociated to Controls.
- Use the same ViewModels for a mobile and tablet Apps. It modifies the ShowViewModel behaviour, allowing you to show Controls, not just change Views.
- Implemented for iPad, Windows Store, Android Tablet Apps and Wpf applications.
##Sample
##Adding to your project
-
Add it from NuGet: https://www.nuget.org/packages/MupApps.MvvmCross.Plugins.ControlsNavigation
-
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); }
-
Create a /Controls folder
-
Inherit your controls from MvxStoreControl, MvxAndroidControl or MvxTouchControl with the same name of the ViewModel but ending in Control (Ex: SecondViewModel -> SecondControl)
-
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 />
```