Set Line Position in XAML

SyntaxEditor for WPF Forum

Posted 1 month ago by Matthew Salomon
Version: 19.1.0686
Avatar

Hello,

I would like to implement a go to line feature in my WPF SyntaxEditor and need a way to bind the line/caret position to a property in my ViewModel. I've seen ways to set the caret position in the code behind(ActiveView.Selection.CaretPosition) but I would like to keep the logic of this interaction outside of the view.

Thanks!

Comments (1)

Answer - Posted 1 month ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Matthew,

I'm sorry but since the property is nested deep in non-dependency objects, there isn't a way to directly two-way bind a VM to it.

You could handle the SyntaxEditor.ActiveViewChanged and ViewSelectionChanged events in your view and then call a NotifyCaretPositionChanged method on your VM from those to update its CaretPosition property.  And perhaps in your VM add an event that is raised when the VM's CaretPosition changes, that the view can watch and update the ActiveView.Selection.CaretPosition property with.


Actipro Software Support

The latest build of this product (v2020.1.1) was released 7 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.