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'
为什么我得到这个,以及如何使路由事件工作?