Exemple #1
0
        protected override void OnAttached()
        {
            base.OnAttached();
            if (this.AssociatedObject.DataContext is EmployeeInfoViewModel)
            {
                viewModel = this.AssociatedObject.DataContext as EmployeeInfoViewModel;
            }
            else
            {
                fileExplorerViewModel = this.AssociatedObject.DataContext as FileExplorerViewModel;
            }

            this.AssociatedObject.RequestTreeItems += AssociatedObject_RequestTreeItems;
        }
Exemple #2
0
 void AssociatedObject_RequestTreeItems(object sender, TreeGridRequestTreeItemsEventArgs args)
 {
     if (args.ParentItem == null)
     {
         //get the root list - get all employees who have no boss
         args.ChildItems = EmployeeInfoViewModel.GetEmployees().Where(x => x.ReportsTo == -1); //get all employees whose boss's id is -1 (no boss)
     }
     else //if ParentItem not null, then set args.ChildList to the child items for the given ParentItem.
     {
         //get the children of the parent object
         EmployeeInfo emp = args.ParentItem as EmployeeInfo;
         if (emp != null)
         {
             //get all employees that report to the parent employee
             args.ChildItems = EmployeeInfoViewModel.GetEmployees().Where(x => x.ReportsTo == emp.ID);
         }
     }
 }
Exemple #3
0
 protected override void OnAttached()
 {
     base.OnAttached();
     this.viewModel = this.AssociatedObject.DataContext as EmployeeInfoViewModel;
     this.AssociatedObject.RequestTreeItems += AssociatedObject_RequestTreeItems;
 }