I just want to show one more examples of binding.
Beside binding of TreeView to which I already gave an example here, there is another possibility of TreeView binding.
For this example I don't need model, so my view model looks like this:
public class ClassBinding
{
public List<string> MyTest
{
get
{
List<string> pom = new List<string>();
pom.Add("test");
return pom;
}
}
public ClassBinding MyContextTest
{
get
{
return new ClassBinding();
}
}
}
My XAML for tree view binding looks like this:
<Grid>
<TreeView DataContext="{Binding Path=MyContextTest}" ItemsSource="{Binding MyTest}"/>
</Grid>
Notice line {Binding Path=MyContextTest} then notice that MyContextClass is property of the class ClassBinding.
Example project you can download from here.
This article I wrote with help of my colleague from ISE.