質問
私のアプリケーションは次のようになります:
1 Window
2 Frame
3 Page
4 Control
コントロール(4)には、カスタムルーティングイベントがあります。フレーム(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を見つけることができません。
解決
のoferertypeを参照してください PreviewArtistLinkClickedEvent
, 、それはあなたの場合のハイパーリンクです、私があなたのコードから得ている限り、この場合の独自の型は TrackList
したがって、あなたのコードは次のようになります:
public static readonly RoutedEvent PreviewArtistLinkClickedEvent = EventManager.RegisterRoutedEvent(
"PreviewArtistLinkClicked", RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TrackList));
お役に立てれば!!
所属していません StackOverflow