hmm I seem to have a problem, on my main window I am trying to do this:
public static readonly DependencyProperty StudentIDProperty = DependencyProperty.Register("StudentID", typeof(String), typeof(LoginWindow), new PropertyMetadata(OnStudentIDChanged));
public string StudentID
{
get { return (string)GetValue(StudentIDProperty); }
set { SetValue(StudentIDProperty, value); }
}
static void OnStudentIDChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
(d as LoginWindow).OnStudentIDChanged(e); //
}
On my other window I have this:
MainWindow.StudentID = (String)((Button)sender).Tag;
But I get the error:
An object reference is required for the non-static field, method, or property 'WpfApplication4.MainWindow.StudentID.get'
Does anyone know how I can fix this? It works for my user controls but not other windows?
My main window is actually named MainWindow so I may have had this confused.
You need to set StudentID on an instance of your MainWindow class. Try