I define a dependency Property for my class1, which raise an event. I don't know why it give me this error "Cannot convert lambda expression to type '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); }));
}
}
Very simple Class1 code :
public class Class1
{
public delegate void myhandler(object sender, EventArgs e);
public event myhandler test;
public void connection()
{
test(this, new EventArgs());
}
}