I have implemented AvalonEdit in my application. Everything works fine except one little hitch - if I change the contents of the editor manually via the Text property while the editor is not visible (eg. it is on the other tab), the contents of the editor won't change. Then when I do any change to the text in the editor itself, the value of the property is overwritten with the value from the editor.
How can I manually tell the 开发者_如何学运维editor to reload its contents from the Text property?
Thanks for help!
AvalonEdit doesn't have any redundant text storage - setting the Text property directly writes to the underlying document.
I would suspect that you aren't setting the Text correctly; or that it's your app that is somehow restoring the old value.
Are you using some kind of data-binding on the Document property; or on the Text property? (the latter doesn't support data-binding)
The solution was somewhere else: I didn't realize WPF called Loaded event more than once (e.g. every time tab is switched) and I used it to initialize the editor's value (so it got reset every time I switched to the tab with the editor, but was fine when I was on the same tab).
精彩评论