Я хочу показать и скрыть определенные макеты, используя кнопку и свойство с привязкой видимости mvvmcross.
Редактировать: Фактическая проблема заключается в том, что, если я разверну проект, эта команда не будет работать, и макеты будут отображаться, когда будет отображаться только первая.
ViewModel:
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();
}
}
AXML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:background="@drawable/background">
<!-- HOME NO LOGGED -->
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<!-- Es imperativo que el ScrollView solo tenga un hijo-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<!-- Login Layout-->
<LinearLayout
android:id="@+id/loggingLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
local:MvxBind="Visibility InvertedVisibility(HideRegisterView)">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/icon" />
<!-- Square Login fields-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#BFFFFFFF">
<TextView
android:id="@+id/usernameLoginTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="-_Username:"
android:textSize="16dp"
android:textColor="@color/text_login"
local:MvxBind="Text UsernameLoginTV" />
<EditText
android:id="@+id/usernameLoginET"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:paddingLeft="2dp"
android:hint="username"
android:textSize="16dp"
android:maxLines="1"
android:background="@color/text_button"
local:MvxBind="Hint UsernameHint" />
<TextView
android:id="@+id/passwordLoginTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="-_Password:"
android:textSize="16dp"
android:textColor="@color/text_login"
local:MvxBind="Text PasswordLoginTV" />
<EditText
android:id="@+id/passwordET"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:hint="-_password"
android:inputType="textPassword"
android:textSize="16dp"
android:maxLines="1"
android:background="#f9f9f9"
local:MvxBind="Hint PasswordHint" />
<!-- Login Button -->
<Button
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:background="#00cc66"
android:text="-_Iniciar Sesion"
android:textColor="@color/text_button"
android:textSize="18dp"
local:MvxBind="Text LoginButtonText" />
</LinearLayout>
<!-- Register Button -->
<Button
android:id="@+id/registerButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:background="#4db8ff"
android:gravity="center"
android:text="-_Registrar"
android:textColor="@color/text_button"
android:textSize="18dp"
local:MvxBind="Text RegisterButtonText; Click ShowRegisterSquare" />
</LinearLayout>
<!-- Register Layout-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#BFFFFFFF"
local:MvxBind="Visibility Visibility(HideRegisterView)">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="-_Username:"
android:textColor="@color/text_login"
android:textSize="16dp"
local:MvxBind="Text UsernameLoginTV" />
<EditText
android:id="@+id/usernameRegisterInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:paddingLeft="2dp"
android:hint="username"
android:textSize="16dp"
android:maxLines="1"
android:background="@color/text_button"
local:MvxBind="Hint UsernameHint" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="-_Password:"
android:textSize="16dp"
android:textColor="@color/text_login"
local:MvxBind="Text PasswordLoginTV" />
<EditText
android:id="@+id/passwordRegisterInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:hint="password"
android:textSize="16dp"
android:inputType="textPassword"
android:maxLines="1"
android:background="#f9f9f9"
local:MvxBind="Hint PasswordHint" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="-_Password:"
android:textSize="16dp"
android:textColor="@color/text_login"
local:MvxBind="Text PasswordLoginTV" />
<EditText
android:id="@+id/passwordConfirmRegister"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:hint="password"
android:textSize="16dp"
android:inputType="textPassword"
android:maxLines="1"
android:background="#f9f9f9"
local:MvxBind="Hint ConfirmPasswordHintRegister" />
<Button
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:background="#00cc66"
android:text="-_Iniciar Sesion"
android:textColor="@color/text_button"
android:textSize="18dp"
local:MvxBind="Text RegisterButtonText" />
</LinearLayout>
</LinearLayout>
</ScrollView>
Я думаю, что этоне правильно, но должно было сработать ... Спасибо за помощь!