wpf - Adding a menu item to a FlowDocumentReader ContextMenu -


the flowdocumentreader has 2 menu items in contextmenu, copy , select all. i'd add additional menuitem , have tried this:

    private void flowdocumentreader_contextmenuopening(object sender, contextmenueventargs e)     {         flowdocumentreader.contextmenu.items.clear();         menuitem menuitem = new menuitem();         menuitem.header = "test";         flowdocumentreader.contextmenu.items.add(menuitem);     } 

additionally i've tried this:

    private void flowdocumentreader_contextmenuopening(object sender, contextmenueventargs e)     {         menuitem menuitem = new menuitem();         menuitem.header = "test";         flowdocumentreader.contextmenu.items.add(menuitem);     } 

where don't clear items in context menu , attempt append it. neither of these work.

i can create own menu so:

    private void flowdocumentreader_contextmenuopening(object sender, contextmenueventargs e)     {         menuitem menuitem = new menuitem();         menuitem.header = "test";         flowdocumentreader.contextmenu.items.add(menuitem);         e.handled = true;         contextmenu menu = new contextmenu();         menuitem = new menuitem();         a.header = "a";         menu.items.add(a);         menuitem b = new menuitem();         b.header = "b";         menu.items.add(b);         flowdocumentreader.contextmenu.items.clear();         flowdocumentreader.contextmenu = menu;         menu.isopen = true;     } 

and that'll show up, i'd have copy , select menu items , b.

ideas?

you in xaml flowdocument:

<flowdocument.contextmenu>      <contextmenu>           <menuitem header="{resx copy}" command="copy"/>           <menuitem header="{resx selectall}" command="selectall"/>           <menuitem header="{resx customcommand}" command="{binding customcommand}"/>      </contextmenu> </flowdocument.contextmenu> 

(headers conveniently localized grant frisken's resx extension) :)

if needs applied many flowdocuments, define in default style somewhere:

<style targettype="flowdocument">     <setter property="contextmenu">          <setter.value>               <contextmenu>                   <menuitem header="{resx copy}" command="copy"/>                   <menuitem header="{resx selectall}" command="selectall"/>                   <menuitem header="{resx customcommand}" command="{binding customcommand}"/>               </contextmenu>          </setter.value>     </setter> </style> 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -