How can I add context menu item to a textBox inside of the FlowDocumentScrollViewer

41 Views Asked by At

I have my PDFDocument bound to the FlowDocumentScrollViewer.

        <FlowDocumentScrollViewer
            Document="{Binding Path=PDFDocument}"                   
            />

How can I add a new context menu item to a text box inside of the viewing area

enter image description here

1

There are 1 best solutions below

0
On

Eventually I found how to do it You can attach the context menu to each of TextBox Elements using a style property setter like this:

<Window.Resources>
    <ContextMenu x:Key="contextMenu" >
        <MenuItem Name="mnuOpen" Header="_Open Link"  Command="{Binding TextBoxContextMenuCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}}"/>
        <MenuItem Name="mnuView" Header="_View Properties" Command="{Binding TextBoxContextMenuCommand}"/>
    </ContextMenu>
    <Style TargetType="TextBox">
        <Setter Property="ContextMenu" Value="{DynamicResource contextMenu}" />
    </Style>
</Window.Resources>