private async void ShowListOfFiles() { if (listoffiles != null) return; var serialFileViewModels = new ObservableCollection<SerialFileViewModel>(); List<FileModel> fileModels = await serialModel.GetListOfSeries(); fileModels.ForEach(x => serialFileViewModels.Add(new SerialFileViewModel(x))); var filesviewModel = new SerialFilesViewModel(serialFileViewModels); filesviewModel.CloseEvent += FilesviewModelOnCloseEvent; listoffiles = new SerialFilesView { Height = Application.Current.MainWindow.ActualHeight, Width = Application.Current.MainWindow.ActualWidth, Owner = Application.Current.MainWindow, ShowInTaskbar = false, DataContext = filesviewModel }; listoffiles.Show(); }
private void FilesviewModelOnCloseEvent(object sender, SerialFilesViewModel serialFilesViewModel) { serialFilesViewModel.CloseEvent -= FilesviewModelOnCloseEvent; listoffiles.Close(); listoffiles = null; }