How to add a UserControl inside an Editor View Margin?

SyntaxEditor for WPF Forum

Posted 3 months ago by Stefano T
Version: 24.1.1


I want to implement a feature like the Inheritance Margin of Visual Studio into our IDE.
To do so I had a look at Editor View Margins but, to my understanding, it is possible to only render graphics like Glyphs or Images.
For the moment I handled a button-like behaviour with hit testing during a MouseDown event.

Is there a way to add a child UIElement like a UserControl to it?

Thanks in advance.

Comments (1)

Answer - Posted 3 months ago by Actipro Software Support - Cleveland, OH, USA


EditorViewMarginBase inherits Control meaning it's a templated control.  You could put some kind of Panel in the template, give it a "PART_..." name, and then directly add/remove controls to that Panel if you wanted. 

It's lighter weight to just render the margin in code-behind though.  For instance, our outlining margin is watching mouse move, leave, and down events.  That allows it to show highlights when over certain regions and to respond to clicks on outlining node boxes.  You could do a similar thing to achieve button-like functionality.

Actipro Software Support

The latest build of this product (v24.1.2) 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.