Reputation: 2411
I try to enable code collapsing on AvalonEdit control and I can not enable it properly.
public FoldingManager foldingManager;
public XmlFoldingStrategy foldingStrategy;
to enable code collapsing I insert this code on Window_Loaded
foldingManager = FoldingManager.Install(textEditor.TextArea);
foldingStrategy = new XmlFoldingStrategy();
foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document);
and to update the collapsing I insert to textEditor_TextChanged this code
foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document);
from the Window_Loaded I get only the first collapsing to work (like in the picture the other tags not updated)
the code in textEditor_TextChanged does not work at all
Upvotes: 2
Views: 2179
Reputation: 16439
Your document is not a valid XML document: XML only allows one top-level element, but you have two (<head>
and <body>
).
XmlFoldingStrategy
can therefore only fold the valid part of the document.
If you want HTML folding, you'll need to write your own HtmlFoldingStrategy
.
If you're OK with forcing the HTML to be valid XML, you'll have to add the opening <html>
tag.
Upvotes: 3