5

The Click Event form a Context Menu Item is not raised when the cursor is outside the taskpane. I have no idea how get it working. 90% of the time, the click is outside the task Pane.

enter image description here

When the context menu is openned, the sub menus are often displayed outside the task pane (see picture below). In such cases, the click event from the context Menu is not raised.

I have absolutly no idea how to make this work.

Any ideas?

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
Avlin
  • 500
  • 4
  • 20
  • +1 a similar issue to mine: http://stackoverflow.com/questions/10526118/bug-cant-choose-dates-on-a-datepicker-that-fall-outside-a-floating-vsto-add-in – Jeremy Thompson May 10 '12 at 05:03

1 Answers1

3

The Custom Task Pane has focus problems with WPF Context Menus. Look here.

I have the same problems. Actually I use one of the recommended workarounds (Dispatcher Frame). Is is working, but I am not very happy with this clumsy solution.

Dirk Brockhaus
  • 4,922
  • 3
  • 38
  • 47
  • 1
    Thanks. Note that you should have the CustomPane reference, either wen declared in xaml. This solution may freeze your app if not correctly implemented. And i have to use e.Source rather than LogicalTreeHelper.GetParent((DependencyObject)e.OriginalSource) but not sure. – Avlin Dec 12 '11 at 17:31
  • if office app get locked try this : Public Sub ContextMenuClick(ByVal sender As Object, ByVal e As RoutedEventArgs) Dispatcher.ExitAllFrames() end sub – Avlin Dec 13 '11 at 09:34
  • +1 LogicalTreeHelper condition didn't work for me either. I simply commented it out and it works now. Thanks @Dirk & Avlin – surfen Aug 14 '13 at 22:36
  • Unfortunately, It doesn't work. It blocks other events. Apparently Frame.Continue = False never executes... – surfen Oct 21 '13 at 00:26