❔ How to create commands for my subclassed AvalonEdit control?
Hello,
I am working on a WPF application, a notepad clone, and I am using AvalonEdit as the main editor. Basically I have some MenuItems that I would like to bind them to commands, such as selecting the current line in the editor or deleting it. I also want to create shortcuts for these MenuItems. AvalonEdit already comes with some pre-defined commands according to the doc. I also am not sure how to do this in a correct MVVM way, since I am not sure where to put these specific text editing commands. Most commands I use just have a [RelayCommand] on top of a function I defined, and the reason I am confused is because I wouldn't put these editing commands in the main view model since it shouldn't know about the AvalonEdit.
Scenario:
Just to illustrate further, there is a duplicate line MenuItem in the app's main menubar. Pressing Ctrl+L also duplicates the current line (if I don't want to click on the MenuItem).
Note:
I have already defined functions that carry out functionality like duplicating the line and I currently have in code-behind
...Click += TextEditor.DuplicateLine
...
My questions:
1. How can I create these commands that I want? Where do I define them exactly?
2. How can I bind to AvalonEdit's predefined commands, like the delete line comand?
3. Do I have to create dependency properties for these commands in my subclassed AvalonEdit?1 Reply
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.