Question

I updated an older android project from mvvmcross v2 to mvvmcross v3.

Got one more problem now.

The visibility doesn't work, its doing nothing.

Old solution looked like this (worked fine):

In Setup.cs

protected override IEnumerable<Type> ValueConverterHolders
{
     get { return new[] { typeof(Converters) }; }
}

Converters.cs

using Cirrious.MvvmCross.Converters.Visibility;

namespace Test.Droid
{
    public class Converters
    {
        public readonly MvxVisibilityConverter Visibility = new MvxVisibilityConverter();
    }
}

Any .axml (change visibility of LinearLayout):

 <LinearLayout style="@style/LinearLayoutSmall" local:MvxBind="{'Visibility':{'Path':'TestIsVisible','Converter':'Visibility'}}">



New solution (doesn't work):

In Setup.cs

protected override List<Type> ValueConverterHolders
{
    get { return new List<Type> { typeof(Converters) }; }
}

Converters.cs

using Cirrious.MvvmCross.Plugins.Visibility;

namespace Test.Droid
{
    public class Converters
    {
        public readonly MvxVisibilityValueConverter Visibility = new MvxVisibilityValueConverter();
    }
}

Any .axml

<LinearLayout style="@style/LinearLayoutSmall" local:MvxBind="Visibility TestIsVisible, Converter=Visibility">

There's probably a problem with the swissbinding syntax or I'm using false classes? Any help appreciated!

UPDATE

I forgot these lines:

public override void LoadPlugins(IMvxPluginManager pluginManager)
{
    pluginManager.EnsurePluginLoaded<PluginLoader>();
    pluginManager.EnsurePluginLoaded<Cirrious.MvvmCross.Plugins.Visibility.PluginLoader>();
    base.LoadPlugins(pluginManager);
}

I guess its necessary but now I'm having following error: enter image description here

(from the MvxPluginManager Class)... I checked all references and the dll/project *.Visibility.Droid.dll is referenced in my mainproject and everywhere else...

Was it helpful?

Solution

Without running and debugging a complete sample of your code I can't see what the problem is. One guess is that it could be in the plugin setup for visibility, but that is only a guess. The debug trace for your app might reveal some information on this.

Alternatively, it might be easier to simply try setting up a new project and getting visibility working in that, then comparing that code back to your existing app.


Value Converters in v3 are documented in https://github.com/MvvmCross/MvvmCross/wiki/Value-Converters.

The preferred way of referencing them is simply to let MvvmCross find them by reflection - see the section on https://github.com/MvvmCross/MvvmCross/wiki/Value-Converters#referencing-value-converters-in-touch-and-droid

A sample app, including visibility, is in: https://github.com/MvvmCross/MvvmCross-Tutorials/tree/master/ValueConversion - e.g. https://github.com/MvvmCross/MvvmCross-Tutorials/blob/master/ValueConversion/ValueConversion.UI.Droid/Resources/Layout/View_Visibility.axml

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top