class Hesabs:Hesab { public Hesabs() { AllHesab = new ObservableCollection<hesab>(); } public ObservableCollection<hesab> AllHesab { get; set; } } </hesab></hesab>
public ObservableCollection<hesabs> AllHesab { get; set; } public ObservableCollection<hesabs> FirstHesab { get; set; } public ViewModelHesabs() { CRMEntities crm=new CRMEntities(); var ls = from h in crm.Hesab where (h.FatherID == null) select h; ObservableCollection<hesabs> hes = new ObservableCollection<hesabs>(); foreach (Hesab hh in ls.ToList()) { var ls2 = from h in crm.Hesab where (h.FatherID == hh.ID) select h; Hesabs hesab = new Hesabs(); hesab.Name = hh.Name; hesab.ID = hh.ID; hesab.AllHesab = new ObservableCollection<hesab>(ls2.ToList()); hes.Add(hesab); } FirstHesab = hes; } </hesab></hesabs></hesabs></hesabs></hesabs>
<treeview itemssource="{Binding FirstHesab}"> <treeview.itemtemplate> <hierarchicaldatatemplate itemssource="{Binding AllHesab}" datatype=" {x:Type local:Hesabs}"> <stackpanel orientation="Horizontal"> <textblock text="{Binding Name}" tag="{Binding ID}" /> </stackpanel> </hierarchicaldatatemplate> </treeview.itemtemplate> </treeview>
foreach (Hesab hh in crm.Hesab.ToList())
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)