public SpawnExtractorTab(SpawnExtractorTabViewModel viewmodel)
        {
            InitializeComponent();

            ViewModel = viewmodel;
            viewmodel.FileSelectionChanged += new FileLoadingHandler(viewmodel_FileSelectionChanged);
            viewmodel.PropertyChanged += new PropertyChangedEventHandler(viewmodel_PropertyChanged);
            viewmodel.TemplateAppliedToNpcs += new TemplateApplied(viewmodel_TemplateAppliedToNpcs);

            var categories = viewmodel.Templates.GroupBy(x => x.Category);
            foreach (var cat in categories)
            {
                var itemCategory = new TreeViewItem();
                itemCategory.Header = cat.Key;

                foreach (var i in cat)
                {
                    var item = new TreeViewItem();
                    item.Header = i.Name;
                    itemCategory.Items.Add(item);
                }

                TreeView.Items.Add(itemCategory);
            }

            TreeView.SelectedItemChanged += new RoutedPropertyChangedEventHandler<object>(TreeView_SelectedItemChanged);
            NPCDataGrid.AutoGeneratingColumn += new EventHandler<DataGridAutoGeneratingColumnEventArgs>(NPCDataGrid_AutoGeneratingColumn);
            NPCDataGrid.SelectedCellsChanged += new SelectedCellsChangedEventHandler(NPCDataGrid_SelectedCellsChanged);
        }
 public SpawnExtractorRibbonTab(SpawnExtractorTabViewModel vm)
 {
     InitializeComponent();
     DataContext = _viewModel = vm;
 }