Problem

Shared Context Menu Issue

Posted 5 years ago by Avatar David Mullin
(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 5 years ago by Actipro Software Support - Cleveland, OH, USA
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 5 years ago by David Mullin
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 5 years ago by Actipro Software Support - Cleveland, OH, USA
Yes that is correct.

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

Actipro Software Support
Posted 5 years ago by David Mullin
Great!
Information The latest build of this product (2014.2 build 0610) was released 1 month ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.