簡體   English   中英

如何將上下文菜單項添加到FlowDocumentScrollViewer內的textBox中

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

我將我的PDFDocument綁定到FlowDocumentScrollViewer。

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

如何在查看區域內的文本框中添加新的上下文菜單項

在此輸入圖像描述

最終,我找到了解決方法。您可以使用如下樣式屬性設置器將上下文菜單附加到每個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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM