I'm a beginner of sliverlight and MVVM. I can not bind textblock property from another class to UI class using MVVM.
My code is here. Please let me know how to bind textblock property in bellow Authentication.cs.
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.
}
}