我的应用程序如下所示:
1 Window
2 Frame
3 Page
4 Control
在 Control (4) 中,我有一个自定义路由事件,我希望 Frame (2) 处理它。
事件:
public static readonly RoutedEvent PreviewArtistLinkClickedEvent = EventManager.RegisterRoutedEvent(
"PreviewArtistLinkClicked", RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(Hyperlink));
public event RoutedEventHandler PreviewAlbumLinkClicked {
add { AddHandler(PreviewAlbumLinkClickedEvent, value); }
remove { RemoveHandler(PreviewAlbumLinkClickedEvent, value); }
}
void RaisePreviewArtistLinkClickedEvent(object sender, RoutedEventArgs e) {
RoutedEventArgs eventArgs = new RoutedEventArgs(Tracklist.PreviewArtistLinkClickedEvent);
RaiseEvent(eventArgs);
}
和框架 XAML:
<Frame Name="frameContent" Grid.Column="1" Background="#373737" NavigationUIVisibility="Hidden"
gui:Tracklist.PreviewArtistLinkClicked="frameContent_PreviewArtistLinkClicked"/>
编译正常,但会发生这种情况:
找不到名为“PreviewArtistLinkClicked”的属性的 DependencyProperty 或 PropertyInfo。