Clickable Link as child of InkCanvas RRS feed

  • Question

  • I'm trying to put a hyperlink in an InkCanvas, but whenever the EditingMode for the InkCanvas is not None (or the link is selected), I cannot click on the link.  I'd really like to use the built-in UIElement select/move/resize functionality of the InkCanvas to manipulate the link, but I also need to be able to click the link.  Does anyone know of a way to make the link always clickable?  Here is the XAML that I'm working with:


    Code Snippet

    <Window x:Class="Window6"



    Title="Window6" Height="300" Width="300">


    <InkCanvas EditingMode="Ink">


    <Hyperlink Name="MyLink" NavigateUri="" FontFamily="Times New Roman" FontSize="12" Foreground="Blue"


    <Run Text="My Link" />







    If you change the EditingMode of the InkCanvas to "None" you can click on the link, but, if it's set to Ink, it will only Ink on top of it.  I would appreciate any help I can get on this.



    Tuesday, July 15, 2008 5:05 PM

All replies

  • I ended up creating a custom class that the selection tool could still interact with and then created a custom adorner to intercept the click events.  In the Loaded event for the class, I create the adorner using the instance of the class.  Then in the adorner, I subscribe to the MouseLeftButtonDown, MouseLeftButtonUp, and PreviewMouseLeftButtonDown events to hittest.  If you set the e.Handled = true in the MouseLeftButtonXXX events, it will prevent the strokes from being put on the InkCanvas, and if you set e.Handled = true in the PreviewMouseLeftButtonDown it will prevent the DynamicRenderer from drawing as well.  Then I just call down to my custom class and have it event out the RequestNavigate event and the InkCanvas doesn't need to know anything about any of this.

    Wednesday, July 16, 2008 5:02 PM