Silverlight – How to bind TreeViewItem.isexpanded data to node data objects

I have a class like hierarchical data

public class MyNode 
{
public string Name {get; set;}
public bool IsExpanded {get; set;}
public List Nodes {get; set;}
}

I can Define a HierarchicalDataTemplate to bind the MyNode class to TreeView.







The question is how to bind the IsExpanded property data of TreeViewItem to the corresponding MyNode.IsExpanded property, so I can keep this information.

p>

Thank you in advance,
Lex

I’m not sure if this applies In Silverlight, but in WPF, you can use styles to bind to IsExpanded:










I have a class like hierarchical data

< p>

public class MyNode 
{
public string Name {get; set;}
public bool IsExpanded {get; set;}
public List< MyNode> Nodes {get; set;}
}

I can define a HierarchicalDataTemplate to bind the MyNode class to the TreeView.

< sdk:TreeView ItemsSource="{Binding RootNodes}">





< /pre>

The question is how to bind the IsExpanded property of TreeViewItem to the corresponding MyNode.IsExpanded property, so I can keep this information.

Thank you in advance,
Lex

p>

I'm not sure if this applies to Silverlight, but in WPF, you can bind to IsExpanded using styles:

< /p>










Leave a Comment

Your email address will not be published.