Failed to assign to property 'System.Windows.Controls.Primitives.ButtonBase.Click'

冷暖自知 提交于 2019-12-01 20:56:37

The problem is that void button1_Click() is not a valid handler for the Click event. Click is a RoutedEventHandler, which is defined as:

public delegate void RoutedEventHandler(
    Object sender,
    RoutedEventArgs e
)

Note that you can also use void button1_Click(object anyName, EventArgs forTheParams), it just has to match the delegate closely enough to be converted.

I had the scenario where I linked a button to a method like this...

<Button Click="MethodName"..../>

I somehow duplicated the method without knowing and as a result I also got this error. Failed to assign to property 'System.Windows.Controls.Primitives.ButtonBase.Click Hope this can help someone save some time.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!