简体   繁体   中英

How to set visibility for ProgressBar in android MvvmCross Xamarin

I am trying to set visibility for ProgressBar as GONE .


In XML

<?xml version="1.0" encoding="utf-8"?>
<ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    local:MvxBind="Visibility Visibility(ProgressVisibility)"
    android:background="@drawable/sel_custom_progress" />

In ViewModel

private bool _progressVisibility;
public bool ProgressVisibility
{
    get { return _progressVisibility; }
    set { _progressVisibility = value; RaisePropertyChanged(() => ProgressVisibility); }
}

I am setting ProgressVisibility = false;


What is happening : The view is still visible and not getting hidden. How to resolve this.

You need to create a custom value converter for Visibility or you can use Visibility plugin

public class MyVisibilityValueConverter : MvxBaseVisibilityValueConverter<bool>
{
    protected override MvxVisibility Convert(string value, object parameter, CultureInfo culture)
    {
        return (value ==true) ? MvxVisibility.Visible : MvxVisibility.Collapsed;
    }
}

xml:

local:MvxBind="Visibility ProgressVisibility,Converter=MyVisibility

More info here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM