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

问题描述 投票:0回答:1

我将PDFDocument绑定到FlowDocumentScrollViewer。

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

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

enter image description here

wpf contextmenu flowdocumentscrollviewer
1个回答
0
投票

最终我发现了如何操作您可以使用样式属性设置器将上下文菜单附加到每个TextBox元素,如下所示:

<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>
© www.soinside.com 2019 - 2024. All rights reserved.