2012-04-12 70 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

相關問題