L'événement routé personnalisé échoue!
-
20-09-2019 - |
Question
Mon application ressemble à ceci:
1 Window
2 Frame
3 Page
4 Control
En contrôle (4) J'ai un événement routé personnalisé, que je veux que le cadre (2) gère.
L'événement:
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);
}
Et le cadre XAML:
<Frame Name="frameContent" Grid.Column="1" Background="#373737" NavigationUIVisibility="Hidden"
gui:Tracklist.PreviewArtistLinkClicked="frameContent_PreviewArtistLinkClicked"/>
Compile bien mais cela se produit:
Impossible de trouver DependencyProperty ou PropertyInfo pour la propriété nommée «préviewartistLinkClicked».
La solution
Voir le propriétaire de PreviewArtistLinkClickedEvent
, C'est un lien hypertexte dans votre cas, pour autant que je tire de votre code, le type propriétaire dans ce cas devrait être TrackList
Alors votre code ressemblera à ceci:
public static readonly RoutedEvent PreviewArtistLinkClickedEvent = EventManager.RegisterRoutedEvent(
"PreviewArtistLinkClicked", RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TrackList));
J'espère que cela t'aides!!
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow