Exemplo n.º 1
0
        private void btnAddElements_Click(object sender, RoutedEventArgs e)
        {
            if (lbDisplayList.SelectedItem != null)
            {
                DisplayInfoTypes element = StringToDisplayInfo((string)lbDisplayList.SelectedItem);
                _settings.Display.Add(element);

                int index = lbDisplayList.SelectedIndex;
                DisplayInfoList.Remove(element);

                lblDisplayElement.GetBindingExpression(ListBox.ItemsSourceProperty).UpdateTarget();
                lbDisplayList.GetBindingExpression(ListBox.ItemsSourceProperty).UpdateTarget();

                lblDisplayElement.SelectedIndex = lblDisplayElement.Items.Count - 1;

                if (lbDisplayList.Items.Count > 0)
                {
                    if (index < lbDisplayList.Items.Count)
                    {
                        lbDisplayList.SelectedIndex = index;
                    }
                    else
                    {
                        lbDisplayList.SelectedIndex = --index;
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void GenerateDisplayList()
 {
     DisplayInfoList.Clear();
     foreach (DisplayInfoTypes element in Enum.GetValues(typeof(DisplayInfoTypes)))
     {
         if (!_settings.Display.Exists(x => x == element))
         {
             DisplayInfoList.Add(element);
         }
     }
 }