Blacker.MangaScraper.Helpers.ListBoxExtension.ResynchList C# (CSharp) 메소드

ResynchList() 개인적인 정적인 메소드

private static ResynchList ( System.Windows.Controls.ListBox listBox ) : void
listBox System.Windows.Controls.ListBox
리턴 void
        private static void ResynchList(ListBox listBox)
        {
            if (listBox != null)
            {
                listBox.SetValue(IsResynchingPropertyKey, true);

                IList list = GetSelectedItemsSource(listBox);
                if (listBox.SelectionMode == SelectionMode.Single)
                {
                    listBox.SelectedItem = null; if (list != null)
                    {
                        if (list.Count > 1)
                        {
                            // There is more than one item selected, but the listbox is in Single selection mode
                            throw new InvalidOperationException("ListBox is in Single selection mode, but was given more than one selected value.");
                        }
                        if (list.Count == 1)
                            listBox.SelectedItem = list[0];
                    }
                }
                else
                {
                    listBox.SelectedItems.Clear();
                    if (list != null)
                    {
                        foreach (object obj in listBox.Items)
                        {
                            if (list.Contains(obj))
                                listBox.SelectedItems.Add(obj);
                        }
                    }
                }
                listBox.SetValue(IsResynchingPropertyKey, false);
            }
        }