I have this 4 table in SQL Server 2012
DepartmentsTbl
DepID ------- DepName
1 ------- Human Resources
2 ------- Financial Management
SpecialTbls:
SpclID ------- SpclName
1 ------- Manager
2 ------- Secretary
3 ------- Data entry
EmployeesTbl:
EmpID ------- EmpName
1 ------- Jack
2 ------- Mark
3 ------- Sara
JobDescriptionTbls:
JDID ------- EmpID ------- DepID ------- SpclID
1 ------- 1 ------- 1 ------- 1
2 ------- 2 ------- 1 ------- 2
3 ------- 2 ------- 1 ------- 3
Note (some times The Departments has no employees & also must be appear in the treeview)
And I want to show my data in treeview according to Departments names such as that
DepName ------- first node SpecialName --- Second node EmpFullName --- Third node
I use Linq query to get my data and XAML like that:
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Path=DepartmentsTbls}">
<TextBlock Text="{Binding Path=DepName}" Foreground="#FFF59E13" />
<HierarchicalDataTemplate.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=SpecialName}" Foreground="White" />
</DataTemplate>
<HierarchicalDataTemplate.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=EmpFullName}" Foreground="White" />
</DataTemplate>
</HierarchicalDataTemplate.ItemTemplate>
</HierarchicalDataTemplate.ItemTemplate>
</TreeView.ItemTemplate>
var Employees = (from spcl in menof.SpecailTbls
join deps in menof.DepartmentsTbls
on spcl.SoecialID equals deps.DepID
join eJD in menof.EmpJobDescriptionTbls
on deps.DepID equals eJD.DepID
join emps in menof.EmployeesTbles
on eJD.EmpID equals emps.EmpID
select new { spcl.SpecialName,deps.DepName,emps.EmpFullName }).ToList();
tvEmpsName.ItemsSource = Employees;
But my data doesn't appear correctly only first node appear. So my question is where is the wrong here. Thanks.