private void OnEditDeviceDetails(object parameter) { try { if (SelectedDevice != null) { var vm = new EditDeviceViewModel(SelectedDevice, this) { //Set properties if any Title = "[Edit Device Details]" }; var dlg = new AddDeviceDialog() { DataContext = vm }; if (dlg.ShowDialog() != true) { return; } } else { MessageBox.Show("Please select an entry for Edit!", "Edit Device details"); } } catch (Exception ex) { MessageBox.Show("Unexpected error occured during Edit device details. \n" + ex.Message); } }
private void OnAddDeviceDetails(object parameter) { try { var vm = new AddDeviceViewModel(this) { //Set properties if any Title = "[Add Device Details]" }; var dlg = new AddDeviceDialog() { DataContext = vm }; if (dlg.ShowDialog() != true) { return; } } catch (Exception ex) { //Custome message can be shown to the user and INeer exception can be logged in a file MessageBox.Show("Error occured while adding device details. \n" + ex.Message); } }
public DeviceListViewItem() { this.InitializeComponent(); this.DataContextChanged += (s, e) => Bindings.Update(); addDeviceDialog = AddDeviceDialog.GetInstance(); }