Shared Context Menu Issue

SyntaxEditor for WPF Forum

Posted 15 years ago by David Mullin
Version: 9.1.0502
Platform: .NET 3.5
Environment: Windows 7 (64-bit)
Avatar
(I'll admit up front that this may not actually be a bug, but rather a feature...but it seems like an odd behavior.)

If I have a SyntaxEditor control on my window, and I say controlInstance.ContextMenu.Items.Add(...), the SyntaxEditor's Context Menu is modified accordingly - so far, so good.

However, if I close that window and create it again, the SyntaxEditor on the second window will now have the additional the ContextMenu twice. It appears that all instances of the SyntaxEditor share a common ContextMenu.

This presents a further problem in that, since the first window no longer exists, the delegate call for the previously added MenuItem no longer exists, so selecting that MenuItem results in an exception.

I imagine that I could write a routine that walks a ContextMenu and does a deep clone of all of the items, but that would be really painful and I'd rather avoid that.

Is there something that I'm missing here?

David Mullin

[Modified at 08/04/2009 06:56 PM]

Comments (5)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi David,

The default context menu is currently defined in a style. That explains the "static" nature of it.

Maybe we'll have to modify our context menu so it is created in code instead. We'll try and make this change for the next maintenance release.


Actipro Software Support

Posted 15 years ago by David Mullin
Avatar
You know, I thought that it was probably done in a style, but it didn't occure to me to go looking for it.

I belive I found it on or around like 230 in Common.xaml for the SyntaxEditor styles - with it being set on or around line 248. Is that the right one?

Am I correct in my concluse that the productsEditor:SRExtension is not included in the "http://schemas.actiprosoftware.com/winfx/xaml/syntaxeditor" namespace, and that I need to add the following?

xmlns:productsEditor="clr-namespace:ActiproSoftware.Products.SyntaxEditor;assembly=ActiproSoftware.SyntaxEditor.Wpf30"
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Yes that is correct.


Actipro Software Support

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The next build 504 will have the context menu built in code instead of via the Style.


Actipro Software Support

Posted 15 years ago by David Mullin
Avatar
Great!
The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.