Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

MVVM and AvalonEdit

$
0
0

Hello,

I bumped into a problem while trying to write application that uses MVVM pattern and AvalonEdit. I think that it is hard or even impossible to write that kind of application at the moment because you can only bind Document property of TextEditor, other important information about current state of this control can't be saved.

In my view I've got TextEditor which Document field is bound to Document property of ViewModel. There is ObservableCollection of ViewModels which is bound to TabControl's data source. If you change tab, TabControl reuse View. It does so by binding appropriate fields of View to ViewModel. At the moment I can only bind Document property so I lose information about current caret position, current selection and probably TextAnchors (I didn't test that one).

 

There are a few solutions which can be applied:

  • placing TextEditor control in model
  • subclassing TabControl so it won't reuse View

Are there any plans of making AvalonEdit more MVVM friendly?


Viewing all articles
Browse latest Browse all 1764

Trending Articles