0
我創建了以下用戶控件:聲明此路由事件有什麼問題?
public partial class ReplacementPatternEditor : UserControl, INotifyPropertyChanged
{
....
public static readonly RoutedEvent CollectionChanged = EventManager.RegisterRoutedEvent(
"CollectionChanged", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ReplacementPatternEditor));
void RaiseCollectionChangedEvent()
{
RoutedEventArgs newEventArgs = new RoutedEventArgs(ReplacementPatternEditor.CollectionChanged);
RaiseEvent(newEventArgs);
}
...
}
現在,當我嘗試使用我的XAML代碼這裏面路由事件:
<local:ReplacementPatternEditor ItemsSource="{Binding MyItemSource}" CollectionChanged="OnCollectionChanged"/>
我得到在編譯以下錯誤:
The property 'CollectionChanged' does not exist in XML namespace 'clr-namespace:MyNamespace'
爲什麼我得到這個,以及如何使路由事件工作?