MvvmCross可见性绑定不起作用

时间:2018-05-28 09:35:30

标签: c# xamarin xamarin.android mvvmcross

我希望使用按钮和具有mvvmcross可见性绑定的属性来显示和隐藏已确定的布局。

修改 实际的问题是,如果我部署项目,此命令不起作用,并且只显示第一个时显示布局。

视图模型:

method = tuple([TestAa, TestAb])
columns = [[method]*3,["level", "l", "r"]]
tuples = list(zip(*columns))
index = pd.MultiIndex.from_tuples(tuples, names=['method', 'properties'])
df1= pd.DataFrame(columns=index, data=data, dtype=np.float)

AXML:

public class HomeViewModel : MvxViewModel
{
    #region Properties
    #region Literals 
    private string _usernameLoginTV;
    public string UsernameLoginTV
    {
        get { return _usernameLoginTV; }
        set
        {
            _usernameLoginTV = value;
            RaisePropertyChanged(() => UsernameLoginTV);
        }
    }
    private string _usernameHint;
    public string UsernameHint
    {
        get { return _usernameHint; }
        set
        {
            _usernameHint = value;
            RaisePropertyChanged(() => UsernameHint);
        }
    }

    private string _passwordLoginTV;
    public string PasswordLoginTV
    {
        get { return _passwordLoginTV; }
        set
        {
            _passwordLoginTV = value;
            RaisePropertyChanged(() => PasswordLoginTV);
        }
    }

    private string _passwordHint;
    public string PasswordHint
    {
        get { return _passwordHint; }
        set
        {
            _passwordHint = value;
            RaisePropertyChanged(() => PasswordHint);
        }
    }

    private string _passwordRegisterTV;
    public string PasswordRegisterTV
    {
        get { return _passwordRegisterTV; }
        set
        {
            _passwordRegisterTV = value;
            RaisePropertyChanged(() => PasswordRegisterTV);
        }
    }
    private string _confirmPasswordHintRegister;
    public string ConfirmPasswordHintRegister
    {
        get { return _confirmPasswordHintRegister; }
        set
        {
            _confirmPasswordHintRegister = value;
            RaisePropertyChanged(() => ConfirmPasswordHintRegister);
        }
    }
    private string _loginButtonText;
    public string LoginButtonText
    {
        get { return _loginButtonText; }
        set
        {
            _loginButtonText = value;
            RaisePropertyChanged(() => LoginButtonText);
        }
    }

    private string _registerButtonText;
    public string RegisterButtonText
    {
        get { return _registerButtonText; }
        set
        {
            _registerButtonText = value;
            RaisePropertyChanged(() => RegisterButtonText);
        }
    }
    //Boolean property Hider Register View
    private bool _hideRegisterView;
    public bool HideRegisterView
    {
        get { return _hideRegisterView; }
        set
        {
            _hideRegisterView = value;
            RaisePropertyChanged(() => HideRegisterView);
        }
    }
    #endregion
    #region Click
    public IMvxCommand ShowRegisterSquare
    {
        get
        {
            return new MvxCommand(() =>
            {
                HideRegisterView = !HideRegisterView;
            });
        }
    }
    #endregion
    #endregion

    public override Task Initialize()
    {
        UsernameLoginTV = Strings.usernameLoginTV;
        UsernameHint = Strings.usernameLoginHint;
        PasswordLoginTV = Strings.passwordLoginTV;
        PasswordHint = Strings.passwordLoginHint;
        LoginButtonText = Strings.loginButton;
        RegisterButtonText = Strings.registerButton;
        ConfirmPasswordHintRegister = Strings.repeatPassword;
        PasswordRegisterTV = Strings.passwordRegisterTV;

        return base.Initialize();
    }

}

我认为这不正确但应该有效...... 谢谢你的帮助!

1 个答案:

答案 0 :(得分:0)

您是否安装了MvvmCross.Plugin.Visibility Nuget Package?

我已经能够在代码中实现隐藏和显示可见性绑定here