Marc (34) [Avatar] Offline
#1
Hi,
This may be my dumbest question yet, but here goes:
If I need to step outside the walled garden of MvvmCross, and use Xamarin routines directly (e.g. Signature Pad), what must I be aware of?
Is there a "standard" set of functions/code/techniques that must be used to 'access' 'Xamarin' from 'within' MvvmCross?

Thank you,
Marc
Jim Bennett (88) [Avatar] Offline
#2
MvvmCross is just a framework to help you build easily testable apps with good code re-use. It doesn't stop you doing anything you want, it's just a tool. Don't think of outside of MvvmCross as 'Raw' Xamarin, all Xamarin apps are Raw Xamarin, MvvmCross just helps you structure your app better.

I guess what you really mean is how do you use controls that MvvmCross doesn't have binding support for? In that case you add the controls to your AXML/Storyboards as normal, then you have to write the binding code yourself.

It's not that hard to do it - just subscribe to events on the control that would update data, and in these events update the properties on your view model, subscribe to events that perform behaviour and execute a command on the view model. Then subscribe to the NotifyPropertyChanged event on the view model and depending on the property that is updated, update the control.

You can even stay a bit inside the MvvmCross walled garden and create custom bindings - see here: https://www.mvvmcross.com/documentation/fundamentals/custom-data-binding
601898 (2) [Avatar] Offline
#3
MVVC bug
First I want to give you my opinion about your Second edition of Xamarin in action book. Fantastic! Abstract figures are a very good pedagogic procedure.

I have the same fatal error at compile time in Visual Studio for Mac from chapter 6 to the end of the book.

Conflict between versions of MVVM :

using System;
using System.Collections.Specialized;
using System.Windows.Input;
using MvvmCross.iOS.Views;
using Foundation;
using UIKit;
using MvvmCross.Binding.BindingContext;

#pragma warning disable 219

namespace SquareRt.iOS
{
// This class is never actually executed, but when Xamarin linking is enabled it does ensure types and properties
// are preserved in the deployed app
[Foundation.Preserve(AllMembers = true)]
public class LinkerPleaseInclude
{
public void Include(MvxTaskBasedBindingContext c)// HERE fatal compile error
{
c.Dispose();
var c2 = new MvxTaskBasedBindingContext();// AND HERE
c2.Dispose();
}

MESSAGE :

THE TYPE 'MvxTaskBasedBindingContext ... exists in both 'MvvmCross.Binging, version 5.2.1.0 Culture =neutral, and MvvmCross, version 6.2.0.0 ...

In french Visual Studio give also 1 more message :

/Library/Frameworks/Mono.framework/Versions/5.12.0/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(5,5): Warning MSB3276: Des conflits entre différentes versions du même assembly dépendant ont été détectés. Définissez la propriété "AutoGenerateBindingRedirects" sur true dans le fichier projet. Pour plus d'informations, consultez http://go.microsoft.com/fwlink/?LinkId=294190. (MSB3276) (SquareRt.iOS)

I did the suggestion "AutoGenerateBindingRedirects=true" in the project file but no success.

What can I do?

Thank you

Francois

PS the image avatar of the present message is not from me. I don't know where it is coming.
Jim Bennett (88) [Avatar] Offline
#4
Looks like one of your projects has an updated MvvmCross package. The code is meant for a particular version to avoid API changes. Best thing to do is check the NuGet Packages in use and ensure all MvvmCross packages are 5.2.1. If any are on a different version, remove them and re-add the older version.
601898 (2) [Avatar] Offline
#5
Effectively!
Thank you