Visibility binding failed

I am trying to use the Visibility plugin with the FieldBinding plugin with no luck.

Model side:

    /// <summary>
    /// Gets or sets the birthdate.
    /// </summary>
    /// <value>
    /// The birthdate.
    /// </value>
    public DateTime? Birthdate { get; set; }

      

ViewModel side:

public class DisplayUserViewModel : BaseUserViewModel
{
    /// <summary>
    /// The user
    /// </summary>
    public readonly INC<User> User = new NC<User>();
}

      

Have a look, first try:

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="@dimen/ListIconTwoLineTileHeight"
            android:paddingRight="@dimen/ListIconTwoLineTextMarginRight"
            local:MvxBind="Visibility User.Birthdate, Converter=Visibility">

      

Second try:

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="@dimen/ListIconTwoLineTileHeight"
            android:paddingRight="@dimen/ListIconTwoLineTextMarginRight"
            local:MvxBind="Visibility Visibility(User.Birthdate)">

      

But the same result:

MvxBind ( 2574):  33.60 Failed to create target binding for binding Visibility for MvxValueConverterValueCombiner combiner-operation

      

I just took the date of birth as an example, but all the visibility bindings did not work (I have x error messages for the x bindings).


EDIT 1

Others, related to work, link a bunch of text and everything displays well:

      <TextView
         style="@style/TextView.ListWithIcon.Single"
         android:layout_marginTop="@dimen/ListIconTwoLineTextMarginTop"
         local:MvxBind="Text User.FirstName" />

      

I am also trying to bind the same result to an INPC property.


EDIT 2

As suggested by stuart, I tried this:

<TextView
    style="@style/TextView.ListWithIcon.Single"
    android:layout_marginTop="@dimen/ListIconTwoLineTextMarginTop"
    android:layout_marginLeft="@dimen/ListIconTextMarginLeft"
    local:MvxBind="Text Visibility(User.Birthdate)">

      

And the visibility converter to TextView seems to work if Datedate is null:

Birthdate:  Gone

      

But this doesn't seem like the visibility property:

<TextView
    style="@style/TextView.ListWithIcon.SecondLine"
    android:layout_below="@+id/Birthday"
    local:MvxBind="Visibility Visibility(User.Birthdate)"
    android:text="Whatever birthdate" />

      

Displays "Regardless of Date of Birth", while Visibility (User.Birthdate) returns Gone ...


EDIT 3

If you are using the Visible pseudo-visibility, everything works as expected.

<RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="@dimen/ListIconTwoLineTileHeight"
            android:paddingRight="@dimen/ListIconTwoLineTextMarginRight"
            local:MvxBind="Visible User.Birthdate">

      

+4


source to share


2 answers


I had the same problem with LinearLayout:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical"
    android:background="@color/white"
    local:MvxBind="Visibility Visibility(IsLoading)">

      

LinearLayout visibility is not tied to my view model:



Failed to create binding binding for Visibility binding for MistxValueConverterValueCombiner-adder

Solution: Add an entry to LinkerPleaseInclude.cs so that the Visibility property is not removed from the view:

public void Include(LinearLayout layout)
{
    layout.Click += (s, e) => layout.Visibility = layout.Visibility - 1;
}

      

+3


source


There are 2 scenarios:

  1. If you are using MvvmCross 5 and below you need to use:

a) local:MvxBind="Visibility Visibility(User.Birthdate)"

in your opinion

b) add a VisibilityPluginBootstrap.cs file to your Bootstrap folder, which will look like this:



 using MvvmCross.Platform.Plugins;

    namespace YourNameSpace.Droid.Bootstrap
    {
        public class VisibilityPluginBootstrap
            : MvxPluginBootstrapAction<MvvmCross.Plugins.Visibility.PluginLoader>
        {
        }
    }

      

enter image description here

  1. If you are using MvvmCross 6 and above, you only need to use:

    local:MvxBind="Visible User.Birthdate"

    In your opinion

and no Bootstrap file needed:

0


source







All Articles