如何将上下文菜单项添加到FlowDocumentScrollViewer内的textBox中

时间:2019-03-12 16:58:34

标签: wpf contextmenu flowdocumentscrollviewer

我将我的PDFDocument绑定到FlowDocumentScrollViewer。

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

如何在查看区域内的文本框中添加新的上下文菜单项

enter image description here

1 个答案:

答案 0 :(得分:0)

最终我找到了怎么做 您可以使用如下样式属性设置器将上下文菜单附加到每个TextBox Elements:

<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>