public ProjectsTabControl() { ViewModel = WpfFactory.CreateViewModel <ProjectsTabControlModel>(); ViewModel.OnAssetsUpdate += () => { Dispatcher.Invoke(() => { RenderFiles(ViewModel.SelectedProject); }); }; InitializeComponent(); this.WhenActivated(d => { RefreshBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.RefreshCommand) .DisposeWith(d); AddProjectBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.AddProjectCommand) .DisposeWith(d); StageBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.StageCommand) .DisposeWith(d); PackageBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.PackageCommand) .DisposeWith(d); CopyModBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.CopyModCommand) .DisposeWith(d); LaunchGameBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.StartGameCommand) .DisposeWith(d); DevExpressBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.DevExpressCommand) .DisposeWith(d); /*GameVersionSelectorCombo * .Events() * .SelectionChanged * .Select(e => e.Source as ComboBox) * .Select(c => c.SelectedIndex) * .InvokeCommand(ViewModel.SetGameVersionCommand) * .DisposeWith(d);*/ /*ViewModel * .WhenAnyValue(vm => vm.SelectedGame) * .Select(gameVersion => (int)gameVersion) * .BindTo(this, v => v.GameVersionSelectorCombo.SelectedIndex) * .DisposeWith(d);*/ ProjectsList .Events() .SelectionChanged .Select(e => ((ListItem <Guid, string>?)ProjectsList.SelectedItem)?.Key) .WhereNotNull() .BindTo(ViewModel, vm => vm.SelectedProject) .DisposeWith(d); ViewModel .WhenAnyValue(vm => vm.SelectedProject) .WhereNotNull() .Where(v => v != Guid.Empty) .Subscribe(RenderFiles) .DisposeWith(d); ViewModel .WhenAnyValue(vm => vm.ProjectList) .Select(list => list .ToList() .Select(project => new ListItem <Guid, string>(project.Id, project.Name))) .Subscribe(items => { ProjectsList.Dispatcher.InvokeAsync(() => { ProjectsList.ItemsSource = items; if (items.Any() && ViewModel.SelectedProject == Guid.Empty) { ProjectsList.SelectedIndex = 0; } }); }) .DisposeWith(d); TreeViewAddContextBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.AddProjectFilesCommand) .DisposeWith(d); TreeViewDeleteContextBtn .Events() .Click .Select(e => { var selectedItems = FilesTreeView.SelectedItems .Cast <FileTreeViewNode>() .ToList(); return(selectedItems .Select(item => item.FileId) .ToList() as IReadOnlyCollection <Guid>); }) .InvokeCommand(ViewModel.DeleteAssetsCommand) .DisposeWith(d); ListBoxDeleteContextBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.DeleteProjectCommand) .DisposeWith(d); ListBoxEditContextBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.EditProjectCommand) .DisposeWith(d); }); FilesTreeView.SelectedItemChanged += FilesTreeView_SelectedItemChanged; FilesTreeView.Focusable = true; }