public void AddTvChannel() { var dialog = new AddUpdateChannelDialog(); dialog.Closing += (sender, args) => { if (dialog.DataContext is AddUpdateChannelViewModel vm) { if (vm.Channel != null && !TvChannels.Any(x => x == vm.Channel)) { TvChannels.Insert(0, vm.Channel); } else { for (int i = 0; i < TvChannels.Count; i++) { if (TvChannels[i].Id == vm.Channel.Id) { TvChannels[i] = vm.Channel; break; } } } } }; dialog.ShowDialogWindow(new AddUpdateChannelViewModel(dialog)); }
public void EditTvChannel(object sender) { var channel = (Models.Channel.Entities.Channel)((Button)sender).DataContext; var dialog = new AddUpdateChannelDialog(); dialog.Closing += (sender, args) => { if (dialog.DataContext is AddUpdateChannelViewModel vm) { channel = vm.Channel; } }; dialog.ShowDialogWindow(new AddUpdateChannelViewModel(dialog, channel)); }