FlowDocumentReader在其ContextMenu,Copy和Select All中有兩個菜單項。我想一個額外的菜單項添加到它,並嘗試這樣的:向FlowDocumentReader添加菜單項ContextMenu
private void FlowDocumentReader_ContextMenuOpening(object sender, ContextMenuEventArgs e)
{
flowDocumentReader.ContextMenu.Items.Clear();
MenuItem menuItem = new MenuItem();
menuItem.Header = "Test";
flowDocumentReader.ContextMenu.Items.Add(menuItem);
}
另外我已經試過這樣:
private void FlowDocumentReader_ContextMenuOpening(object sender, ContextMenuEventArgs e)
{
MenuItem menuItem = new MenuItem();
menuItem.Header = "Test";
flowDocumentReader.ContextMenu.Items.Add(menuItem);
}
,我不清除在上下文菜單中的項目,試圖追加它。這些都不起作用。
我可以創建自己的菜單,如下所示:
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 a = 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;
}
這會顯示出來,但我想已經是複製和選擇所有的菜單項目,以及A和B.
想法?