Hello all,
I need a scenario in which the item template of OrgChartNodeLayout(in GlobalNodeLayouts) needs to be different based on some conditions.
For example:
<ig:XamOrgChart.GlobalNodeLayouts> <ig:OrgChartNodeLayout TargetTypeName="Department" DisplayMemberPath="DepartmentName" Key="Departments" /></ig:XamOrgChart.GlobalNodeLayouts>
In above example, suppose if Department has sub-Departments, then, one template should be used.
But if that Department doesn't have Sub-Departments,instead ,has Employees, then other template should be used.
The class structure for Department class is :
public class Department { public Department(string name) { this.DepartmentName =name; this.Departments = new ObservableCollection<Department>(); this.Employees = new ObservableCollection<Employee>(); }
public string DepartmentName { get; set; }
public ObservableCollection<Department> Departments { get; set; } public ObservableCollection<Employee> Employees { get; set; } }
If Department has Sub-Departments, the Departments(Observable collection) will have value [Count > 1] and if it doesn't have Sub-Department, then the Employees will have value [Count > 1].
How can I achieve different Item Template based on above conditions? [For List Box , there is itemTemplateSelector, is there any similar approach in this one? ]
Thank you in advance for your time.
Help..
Thanks Andrew,
For now, the problem is solved. So, thanks for all your help and suggestions.
I will let you know if i need any further assist regarding this matter.
For now, it's ok.
Thanks once again.
Regards,
Ram.
Hello Ram,
I am glad that you were able to find a solution to this issue. Is there anything else I may be able to assist you with regarding this matter?
Sincerely,AndrewDeveloper Support IInfragistics Inc.www.infragistics.com/support
HI,
Thanks for the reply.
I haven't tried your solution but I think I have solved the problem (without using SubDepartment).
I 'll try the solution provided by you as well.
What I did was " I kept both two templates content into the one template and among those two, only one is called at a time, so the other one is not called.(Based) on data conditions. "
Thanks,
I went back and added the SubDepartment class again as I felt it was necessary to achieve the functionality you are looking for. The Department class now only has a name and a collection of SubDepartments, as it acts as the top node of the XamOrgChart. The SubDepartment class now has two collections, with one of Employees and the other of SubDepartments.
In the XAML, I set the SubDepartment ItemTemplate up to include a StackPanel with a TextBlock that displays the name of the SubDepartment and then a ListBox to list the employees if there are any. If there aren’t any, I set up a Converter to toggle the Visibility of the ListBox to collapsed if it’s Items.Count property is 0.
I have attached a sample demonstrating the above.
Please let me know if you have any questions or concerns.
Your example above has brought more clarity to this issue. I am still working on it for you, and I should have a solution or more information for you soon.