【发布时间】:2015-05-06 21:16:03
【问题描述】:
我为我的 class1 定义了一个依赖属性,它引发了一个事件。我不知道为什么它会给我这个错误“无法将 lambda 表达式转换为类型 'System.Delegate'”
public static readonly DependencyProperty class1Property =
DependencyProperty.Register("class1Property", typeof(Class1), typeof(UserControl1), new PropertyMetadata(null));
public Class1 class1
{
get
{
return Dispatcher.Invoke((() => GetValue(class1Property)))as Class1;
}
set
{
Dispatcher.Invoke(new Action(() => { SetValue(class1Property, value); }));
}
}
非常简单的 Class1 代码:
public class Class1
{
public delegate void myhandler(object sender, EventArgs e);
public event myhandler test;
public void connection()
{
test(this, new EventArgs());
}
}
【问题讨论】:
标签: c# lambda dependency-properties