Bind Treeview in WPF
TreeView Xmal
<treeview x:name= "Tvworkitem" grid.column= "0" grid.row= "2" background= "Black" itemssource= "{Bindi ng Menudatasource} "selecteditemchanged=" Treeview_onselecteditemchanged > <t Reeview.itemtemplate > <span style= "color: #ff0000;" >
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/net/
ViewModel
Private observablecollection<menuitem> _menudatasource;
Public observablecollection<menuitem> menudatasource
{
get
{
if (_menudatasource = null)
_menudatasource = Menuoperation.loadmenu ();
return _menudatasource;
}
Set
{
_menudatasource = value;
raisePropertyChanged (() => menudatasource);
}
Entity
public class MenuItem {public Guid Id {get; set;}
public string Name {get; set;}
public string Oriname {get; set;}
public bool Hasoutstandingtask {get; set;} Public <span style= "color: #ff0000;"
>ObservableCollection<MenuItem></span> ChildItems {get; set;}
public bool Isworkitemtype {get; set;}
Public WorkItemType Worktype {get; set;}
public bool Isworkitem {get; set;} }