
Hello Actipro,
my application
- loads a new view incl. a new XML SyntaxEditor within the main window
- collapes XML elements onload (see code below)
- unloads the view and its viewmodel (i.a. view.DataContext = null;)
private static void CollapseRecursively(IOutliningNode node)
{
node.IsCollapsed = true;
foreach (var subnode in node)
{
CollapseRecursively(subnode);
}
}
[Conditional("DEBUG")]
private void TEST_CollapseXmlNodes()
{
SyntaxEditor editor = GetSyntaxEditor();
editor.UpdateLayout(); // Without this call the "RootNode" property is always empty.
XmlParseData parseData = (XmlParseData)editor.Document.ParseData;
IAstNode astNode = parseData.Ast.Children.SingleOrDefault();
IOutliningNode rootNode = editor.Document.OutliningManager.RootNode.SingleOrDefault();
if (rootNode != null)
{
foreach (var node in rootNode)
{
CollapseRecursively(node);
}
}
}
When you open the view the first time, it works fine: The necessary elements are collapsed.
"astNode" and "RootNode" have exactly one child. Perfect!
The problem:
After that if you close and open it again nothing is collapsed.
"astNode" and "RootNode" are empty (see also: comment in code).
What can I do?
[Modified 3 years ago]