2012-04-12 69 views
0

我想通过编辑单元格样式将事件处理程序添加到DataTable中的单元格。具体来说,我设置System.Windows.FrameworkElement.TargetUpdated =“...”无效。 'TargetUpdated'必须是RoutedEvent

<EventSetter Event="TargetUpdated" Handler="TaskDescription_TextChanged1Event"/> 

而这里的是我得到的错误:

System.Windows.FrameworkElement.TargetUpdated="TaskDescription_TextChanged1Event" 
    is not valid. 'TargetUpdated' must be a RoutedEvent registered with a name that 
    ends with the keyword "Event". 

下面是TaskDescription_TextChanged1Event代码:

public void TaskDescription_TextChanged1Event(object sender, 
           RoutedEventArgs e) 
    { 

    } 

我应该为此做工作?

回答

2

不能使用EventSetters对于没有路由事件,但是根据文档FrameworkElement.TargetUpdatedBinding.TargetUpdated别名事件,这是路由,所以订阅,可能工作了。

+0

谢谢,这工作。但是,如果我以这种方式设置TaskDescription_TextChanged1Event,则永远不会调用 – 2012-04-12 22:14:15

+0

@ArsenZahray:您是否设置了['NotifyOnTargetUpdated'](http://msdn.microsoft.com/zh-cn/library/system.windows.data.binding.notifyontargetupdated。 aspx)的绑定?另外为什么你不使用['TextChanged'](http://msdn.microsoft.com/en-us/library/system.windows.controls.textbox.textchanged.aspx)或其他? – 2012-04-12 22:30:11

+0

我很想,但我无法弄清楚如何在ContentPresenter中使用TextChanged – 2012-04-13 06:29:36

相关问题