FixedPageViewer can't select text/hyperlinks don't work

Mar 31, 2011 at 2:44 PM

I have a FixedPageViewer in a ScrollViewer as a UserControl. The usercontrol is used in a book to display the individual pages. All that is working just fine. I am trying to implement the stickynote and highlight annotations but I cannot select text in the doc so the highlight does not get enabled on the context menu. I have used the book example and the custom annotation example as my roadmap but something is just not quite right. Also the hyperlinks in the doc do not work. (I Exported from Word 2003 using the XPS printer) I have implemented the tITextContainer in the usercontrol class. On a side note the Ink Command works and I can draw on the doc successfully. I know I am dancing all around it and it is probably something obvious that I just am not seeing. I did notice that in the book example you cannot select text either. Do you have to use the documentviewer in order to get the text selection and hyperlinks?

Mar 31, 2011 at 5:25 PM
Edited Mar 31, 2011 at 5:26 PM

Implementing ITextContainer is good, you do not need the DocumentViewer control for text selection and hyperlinks. I think you are missing the FixedPageAdorner and NavigationBehavior behaviors. They need to be attached to each FixedPageViewer instance. FixedPageAdorner is used to render text selection and annotations. NavigationBehavior handles hyperlink navigation. See also the default style of the DocumentViewer.

Does this help?

- Koen

Mar 31, 2011 at 7:25 PM

Thanks for the push in the direction. You are correct on the Adorners and Behavoirs, I did not bring them in. I am all over it, like a duck on a june bug, now.

Apr 14, 2011 at 3:44 AM

Still no joy in getting the annotations/hyperlinks to work;

I have a use control defined as:

public partial class ctrlSinglePage : UserControl, ITextContainer

my xaml is: (other stuff removed)
            <ScrollViewer x:Name="ScrollViewer" Grid.Row="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
            <Border x:Name="PageViewerBorder"
                        Background="White" BorderBrush="Black"  BorderThickness="1" Margin="4" HorizontalAlignment="Center" VerticalAlignment="Center"
                <doc:FixedPageViewer x:Name="docViewer"
                                     FixedPage="{Binding FixedPage}"
                                     FixedPageSize="{Binding FixedPageSize}"
                                     FixedPageError="{Binding FixedPageError}"

                    <!-- attach ink editor to each fixed page viewer instance-->
                    <notes:InkEditor Settings="{StaticResource InkEditorSettings}" Store="{StaticResource AnnotationStore}" />

I have tried every combination of setting the NavigationBehavior and FixedPageAdorner in both the xaml and code behind, but I cannot get it to allow the selection of text or activate a hypelink.
I am hosting the control in a RadBook control. Everything works fine, the pages load, scale, I can draw on them with the Ink Editor.
From what I can tell, the TextContainer is null when it trys to create a sticky note.
I have tied everything I can think of to bind the TextContainer on the NavigationBehavior and the FixedPageAdoner (TextContainer.Annotations), but no joy.
I added DataContext="{Binding RelativeSource={RelativeSource Self}}" to the declarations and was able to bind to Selection that way and I created
  public ctrlSinglePage TextContainer{
   get{return this;}
in the control as a hail may and tried binding to that.
I am deep in the Rabbit Hole.
Any ideas/suggestions?

Thanks, Mike

Apr 14, 2011 at 6:11 PM
Edited Apr 14, 2011 at 6:12 PM

Hi Mike,

Is your text selection instance enabled? By default it's not. See also the SinglePageSample in the source code.

I need to create another tutorial to explain step by step how to implement and use an ITextContainer with full support for annotation and text selection when DocumentViewer is not used. I will do so when I have time.

- Koen

Apr 14, 2011 at 6:19 PM

In the ITextContainer Implementation Section I Have:

  private TextSelection _Selection = new TextSelection()
   IsEnabled = true
  /// <summary>
  /// Gets the selection.
  /// </summary>
  /// <value>The selection.</value>
  public TextSelection Selection
    return this._Selection;

It seems to be Enabled as the Sticky Note Menu option is available

Apr 14, 2011 at 6:26 PM

Okay, that looks good. So the issue you are having is that you are unable to assign the textselection instance to the FixedPageAdorner?

What you can do is add the TextSelection instance to the resources collection of your user control and use the StaticResource markup extension to reference this instance.

So in your usercontrol ctor do something like:

this.Resources.Add("Selection", this._Selection);

and in your XAML:

<doc:FixedPageAdorner Selection="{StaticResource Selection}" />

Does this make sense?

Apr 14, 2011 at 7:45 PM

I can assign the TextSelection with: Selection="{Binding Selection}"

I have: DataContext="{Binding RelativeSource={RelativeSource Self}}" in the declarations which makes the usercontrol properties available for binding (or so is my understanding) It seems to be working for the Selection binding of the StickyNote command as it is now Enabled (prior to doing this it was always disabled) I tried your suggestion but it throws an error when SL tries to load, 'Cannot find a Resource with the Name/Key'

I know I am just dancing all around it, one lose wire somewhere

I also have a property in the control:

public ctrlSinglePage TextContainer{
   get{return this;}

I tried binding to this for the NavigationBehavior Binding, but it doesn't seem to work.

Apr 14, 2011 at 9:17 PM

Hi Mike,

Is it possible you send me the source of your project? That would make it a lot easier to debug and see what is wrong. My contact details at

- Koen

Apr 14, 2011 at 9:38 PM

No problem, I'll strip it down to the bare minimum and get it off to you this eve. or tommorrow. I am about to get on the road for the next few hours.

Thanks for all your help so far, Mike