うーん、問題があるようです。メインウィンドウでこれを実行しようとしています。
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); //
}
私の他のウィンドウにはこれがあります:
MainWindow.StudentID = (String)((Button)sender).Tag;
しかし、エラーが発生します:
An object reference is required for the non-static field, method, or property 'WpfApplication4.MainWindow.StudentID.get'
誰かが私がこれを修正する方法を知っていますか?それは私のユーザーコントロールでは機能しますが、他のウィンドウでは機能しませんか?
私のメインウィンドウは実際にはMainWindowという名前なので、これが混乱している可能性があります。