SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

MVVM and AvalonEdit

Last post 07-28-2010 3:38 PM by saner. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 07-27-2010 8:56 PM

    • saner
    • Top 500 Contributor
    • Joined on 09-03-2009
    • Posts 13

    MVVM and AvalonEdit

    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?

  • 07-27-2010 9:14 PM In reply to

    Re: MVVM and AvalonEdit

    No, there are no plans to make AvalonEdit more MVVM friendly.

    If you really need to export the state of the editor using MVVM, then I suggest you create a class deriving from TextEditor which adds the necessary dependency properties and synchronizes them with the actual properties in AvalonEdit.

  • 07-28-2010 3:38 PM In reply to

    • saner
    • Top 500 Contributor
    • Joined on 09-03-2009
    • Posts 13

    Re: MVVM and AvalonEdit

    Thanks for suggestion,

    What do you think what information should be available via dependency properties so that the current state of TextEditor can be saved?

Page 1 of 1 (3 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.