在我的主窗口名为(MainWindow错误)我有一个方法获取一个值,一旦它被触发,这适用于我的usercontrols,但由于某种原因,当我尝试这在我的MainWindow没有定义为OnStudentIDChanged。OnStudentIDChanged没有定义
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); // OnStudentIDChanged no definition?
}
而你的MainWindow有一个定义OnStudentIDChanged(DependencyPropertyChangedEventArgs e)? – csteinmueller 2012-04-25 15:32:05
当StudentID属性更改时,您想要执行什么操作? – 2012-04-25 15:36:16
请检查LoginWindow/MainWindow错别字。 – 2012-04-25 15:37:34