// TODO: Make Click event handlers to Command event handlers,
        //       if WPF has 'convinient' MVVM implementation on dialogs
        //       and message box.

        private void EditPart_Click(object sender, RoutedEventArgs e)
        {
            ComputerPart part = (ComputerPart)lvComputerParts.SelectedItem;

            if (part == null)
            {
                // return if no selected item
                return;
            }

            try
            {
                PartDialog dialog = new PartDialog(part)
                {
                    Owner = this
                };
                dialog.ShowDialog();

                if (dialog.DialogResult == true)
                {
                    MainViewModel vm       = (MainViewModel)DataContext;
                    PartViewModel dialogVm = (PartViewModel)dialog.DataContext;
                    vm.EditPart(part, dialogVm.GetPartDetail());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void AddPart_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // initialize dialog with selected item
                PartDialog dialog = new PartDialog
                {
                    Owner = this
                };
                dialog.ShowDialog();

                if (dialog.DialogResult == true)
                {
                    MainViewModel vm       = (MainViewModel)DataContext;
                    PartViewModel dialogVm = (PartViewModel)dialog.DataContext;
                    vm.AddPart(dialogVm.GetPartDetail());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }