예제 #1
0
        private void RemoveItem(object sender, RoutedEventArgs e)
        {
            try
            {
                int index = Lb_Apps.SelectedIndex;

                MessageBoxResult result = MessageBox.Show(
                    string.Format(FindResource("EditWindow_Message_AreYouSureToRemove") as string, al[index].AppName),
                    FindResource("MessageBoxTitle_Message") as string,
                    MessageBoxButton.YesNo
                    );

                if (result == MessageBoxResult.Yes)
                {
                    Lb_Apps.Items.RemoveAt(index);
                    al.RemoveAt(index);

                    if (Lb_Apps.Items.Count > 0)
                    {
                        index = index > 0 ? index - 1 : index;
                        Lb_Apps.SelectedIndex = index;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, FindResource("MessageBoxTitle_Error") as string);
            }
        }