private async void btn_add_Click(object sender, RoutedEventArgs e) { AddDeviceDialog dialog = new AddDeviceDialog(false); ContentDialogResult dialogResult = await dialog.ShowAsync(); if (dialogResult == ContentDialogResult.Primary) { currentAppState.Devices.Add(dialog.ViewModel.Device); await Startup.StoreAppState(currentAppState); } }
private async void btn_editDevice_Click(object sender, RoutedEventArgs e) { AddDeviceDialog dialog = new AddDeviceDialog(true); var selectedDevice = GetSelectedDevice(); var clonedDeviceForEdits = selectedDevice.CloneJson(); dialog.ViewModel.Device = clonedDeviceForEdits; ContentDialogResult dialogResult = await dialog.ShowAsync(); if (dialogResult == ContentDialogResult.Primary) { var index = currentAppState.Devices.IndexOf(selectedDevice); currentAppState.Devices.Remove(selectedDevice); currentAppState.Devices.Insert(index, clonedDeviceForEdits); await Startup.StoreAppState(currentAppState); } }