I have a static singleton class with properties I use to databind textboxes to.
using System.ComponentModel;
namespace Masca
{
public class logged : INotifyPropertyChanged
{
public static logged instance = new logged();
public static logged Instance
{
get { return instance; }
}
private string alisa;
public string aliasname
{
get { return alisa; }
set
{
alisa = value;
RaisePropertyChanged("aliasname");
}
}
private string mail;
public string emailadd
{
get { return mail; }
set
{
mail = value;
RaisePropertyChanged("emailadd");
}
}
private void RaisePropertyChanged(string prop)
{
if (PropertyChanged != null)
{
PropertyChanged (this, new PropertyChangedEventArgs(prop));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
This is the property access method:
loggedin.Instance.emailadd = "email.text";
This is the datacontext I place in the initialize components of all other pages I wish to access the property:
DataContext = loggedin.Instance;
and this is the XAML code for a bound TextBox
<TextBox x:Name="email" Text="{Binding emailadd}" Height="19" VerticalAlignment="Top" HorizontalAlignment="Left" Width="211" FontSize="11" Margin="134,417,0,0"/>
<TextBox x:Name="mail" Text="{Binding emailadd}" Height="19" VerticalAlignment="Top" HorizontalAlignment="Left" Width="211" FontSize="11" Margin="134,435,0,0"/>
The problem is that if I type something into email.text, mail.text will only reflect what is in email.text once i have clicked in mail.text.
Help is much appreciated.