我的xaml视图文件中有<TabControl AllowDrop="True" PreviewDragOver="{Binding Path=DragOver}" PreviewDrop="Drop">
位于ViewModel.cs类中的DragOver函数。
我得到了下面的错误
PreviewDragOver="{Binding Path=DragOver}" is not valid. '{Binding Path=DragOver}' is not a valid event handler method name. Only instance methods on the generated or code-behind class are valid. 我尝试绑定到函数的方式有什么问题?应该是怎样的呢?
发布于 2011-04-30 21:18:58
您只能绑定到viemmodel中的属性,如果需要调用viemodel中的任何函数,则需要通过路由命令来完成。要开始如何实现命令,请查看这些链接,它们可能会有所帮助-
http://www.codeproject.com/KB/WPF/VMCommanding.aspx (1) http://msdn.microsoft.com/en-us/library/ms752308.aspx (2)
发布于 2011-04-30 20:48:42
与PreviewDrop一样,PreviewDragDrop也是一个事件,它希望获得一个适当的事件处理程序。如果DragOver是事件处理程序,那么您的代码应该类似于<TabControl AllowDrop="True" PreviewDragOver="DragOver" PreviewDrop="Drop">
https://stackoverflow.com/questions/5841560
复制相似问题