Пример #1
0
        private static void LoadCandidates(TreeNode parent, FileSystemInfo parentDiectory, ICandidateInfoRepository repository)
        {
            foreach (var document in repository.GetAll(parentDiectory.FullName))
            {
                var item = new TreeNode
                {
                    Text = $"{document.LastName} {document.FirstName}",
                    Tag  = document
                };

                parent.Nodes.Add(item);
            }
        }
Пример #2
0
        private static void LoadCandidates(ItemsControl parent, FileSystemInfo parentDiectory, ICandidateInfoRepository repository)
        {
            foreach (var document in repository.GetAll(parentDiectory.FullName))
            {
                var item = new TreeViewItem
                {
                    Header      = $"{document.LastName} {document.FirstName}",
                    DataContext = document
                };

                item.Selected += (sender, args) =>
                {
                    var tvi  = (TreeViewItem)sender;
                    var grid = (Grid)((Grid)GetWindow(tvi).Content).Children[1];
                    grid.Children.Clear();

                    grid.Children.Add(new EditCandidateControl {
                        DataContext = item.DataContext
                    });
                };

                parent.Items.Add(item);
            }
        }