views:

142

answers:

1

Hello

My application looks like this:

1 Window
  2 Frame
    3 Page  
      4 Control

In Control (4) I have a custom routed event, which i want Frame (2) to handle.

The event:

    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);
    }

And the frame XAML:

            <Frame Name="frameContent" Grid.Column="1" Background="#373737"  NavigationUIVisibility="Hidden"
               gui:Tracklist.PreviewArtistLinkClicked="frameContent_PreviewArtistLinkClicked"/>

Compiles fine but this happens:

Cannot find DependencyProperty or PropertyInfo for property named 'PreviewArtistLinkClicked'.

A: 

See the OwnerType of PreviewArtistLinkClickedEvent, It is Hyperlink in your case, as far i am getting from your code, the OwnerType in this case should be TrackList so your code will look like this:

public static readonly RoutedEvent PreviewArtistLinkClickedEvent = EventManager.RegisterRoutedEvent(
     "PreviewArtistLinkClicked", RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TrackList));

Hope this helps!!

viky
Thank you! That was it.
Erik