private void UpdateUI(CallTreeConvertor treeConvertor) { Dispatcher.BeginInvoke(new Action(() => { var containingUnitViewModels = treeConvertor.SourceFiles.Select(sf => { var methodViewModels = sf.ContainedMethods.Select(cm => new MethodViewModel(cm)); var containingUnitViewModel = new ContainingUnitViewModel(sf.FullName); containingUnitViewModel.Height = sf.Height; containingUnitViewModel.MethodViewModels = methodViewModels.OrderBy(mvm => mvm.Top).ToArray(); return(containingUnitViewModel); }).ToArray(); List <MethodViewModel> allMethodViewModels = new List <MethodViewModel>(); foreach (var containingUnitViewModel in containingUnitViewModels) { allMethodViewModels.AddRange(containingUnitViewModel.MethodViewModels); } _uiLogic.CriteriaContext = treeConvertor.CriteriaContext; _uiLogic.MethodModelByIdDict = treeConvertor.MethodDictionary.ToDictionary(kvp => kvp.Key.Id, kvp => kvp.Value); _uiLogic.MethodVMByIdDict = allMethodViewModels.ToDictionary(kvp => kvp.Id, kvp => kvp); var detailViewModel = new DetailViewModel(); detail.DataContext = detailViewModel; _uiLogic.Detail = detailViewModel; _uiLogic.InitAllMethodViewModels(); containingUnits.ItemsSource = containingUnitViewModels; containingUnits.DataContext = new { Height = treeConvertor.MaxEndLine + 20 }; OnDataUpdate(containingUnitViewModels); var sortedMethodVMs = new ObservableCollection <MethodViewModel>(_uiLogic.MethodVMByIdDict.Values); sortedMethods.DataContext = sortedMethodVMs; _uiLogic.SortedMethodVMs = sortedMethodVMs; _uiLogic.ActivateCriterion(_uiLogic.ActiveCriterion); }), null); }