No se puede vincular la propiedad de bloque de texto de otra clase a la clase de UI usando MVVM
Soy un principiante de sliverlight y MVVM. No puedo vincular la propiedad de bloque de texto de otra clase a la clase UI usando MVVM.
Mi código está aquí. Por favor, hágame saber cómo vincular la propiedad de bloque de texto en Authentication.cs abajo.
MainPage.xaml
<TextBlock Height="30" Margin="122,218,0,0" Name="textBlock3" Text="{Binding Path=ErrorStatus, Mode=TwoWay}" VerticalAlignment="Top" HorizontalAlignment="Left" Width="86" />
MainPage.xaml.cs
private Authentication authentication;
// Constructor
public MainPage()
{
InitializeComponent();
this.DataContext = authentication;
}
ViewModelBase.cs
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
}
Authentication.cs
public class Authentication : ViewModelBase
{
private string _ErrorStatus;
public string ErrorStatus
{
get
{
return _ErrorStatus;
}
set
{
_ErrorStatus = value;
NotifyPropertyChanged("ErrorStatus");
}
}
void Authenticate()
{
//Here, I write authentication code....
//After the authentication code, I want to change textBlock property depend on auth status.
//Please let me know how to write code.
}
}