private void CreateProfil() { var newProfil = new ProfilViewModel(); AddProfileDialog dialog = new AddProfileDialog { DataContext = newProfil, Owner = Application.Current.MainWindow }; var resDialog = dialog.ShowDialog(); if (resDialog.HasValue && resDialog.Value) { newProfil.Command = new RelayCommand(o => SelectProfil((ProfilViewModel)o)); Profils.Add(newProfil); SelectProfil(newProfil); } }