Ejemplo n.º 1
0
 protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
 {
     if (item != base.DataContext)
     {
         base.PrepareContainerForItemOverride(element, item);
         MyListBoxItem myListBoxItem      = (MyListBoxItem)element;
         Style         itemContainerStyle = this.ItemContainerStyle;
         ((FrameworkElement)myListBoxItem).Style = itemContainerStyle;
         int num1 = 1;
         myListBoxItem._isBeingVirtualized = num1 != 0;
         int num2 = this.SelectedItems.Contains(item) ? 1 : 0;
         myListBoxItem.IsChecked = num2 != 0;
         int num3 = this.IsSelectionEnabled ? 2 : 0;
         myListBoxItem.State = (SelectionEnabledState)num3;
         int num4 = 0;
         myListBoxItem.UpdateVisualState(num4 != 0);
         int num5 = 0;
         myListBoxItem._isBeingVirtualized = num5 != 0;
     }
     else
     {
         MyListBoxItem myListBoxItem = (MyListBoxItem)element;
         int           num1          = 0;
         myListBoxItem.IsReorderEnabled = num1 != 0;
         int num2 = 0;
         myListBoxItem.State = (SelectionEnabledState)num2;
         int num3 = 0;
         myListBoxItem.UpdateVisualState(num3 != 0);
         object obj = item;
         ((ContentControl)myListBoxItem).Content = obj;
         DataTemplate dataTemplate = Application.Current.Resources[this.SupportsFooter ? "FooterTemplate" : "ReorderListBoxFooterTemplate"] as DataTemplate;
         ((ContentControl)myListBoxItem).ContentTemplate = dataTemplate;
     }
 }
Ejemplo n.º 2
0
        public void UnselectAll()
        {
            if (this.SelectedItems.Count <= 0)
            {
                return;
            }
            IList removedItems = (IList) new List <object>();

            foreach (object selectedItem in (IEnumerable)this.SelectedItems)
            {
                removedItems.Add(selectedItem);
            }
            for (int index = 0; index < ((PresentationFrameworkCollection <object>)((ItemsControl)this).Items).Count && this.SelectedItems.Count > 0; ++index)
            {
                MyListBoxItem myListBoxItem = (MyListBoxItem)((ItemsControl)this).ItemContainerGenerator.ContainerFromIndex(index);
                if (myListBoxItem != null && myListBoxItem.IsChecked)
                {
                    myListBoxItem._canTriggerSelectionChanged = false;
                    myListBoxItem.IsChecked = false;
                    myListBoxItem._canTriggerSelectionChanged = true;
                }
            }
            this.SelectedItems.Clear();
            this.OnSelectionChanged(removedItems, (IList) new object[0]);
        }
Ejemplo n.º 3
0
        private static void ItemStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MyListBoxItem myListBoxItem = d as MyListBoxItem;

            if (!(((FrameworkElement)myListBoxItem).DataContext is IMarker))
            {
                return;
            }
            myListBoxItem.State = SelectionEnabledState.Closed;
        }
Ejemplo n.º 4
0
 private void CloseSelection()
 {
     base.Dispatcher.BeginInvoke((Action)(() =>
     {
         for (int index = 0; index < ((PresentationFrameworkCollection <object>)((ItemsControl)this).Items).Count; ++index)
         {
             MyListBoxItem myListBoxItem = (MyListBoxItem)((ItemsControl)this).ItemContainerGenerator.ContainerFromIndex(index);
             if (myListBoxItem != null)
             {
                 myListBoxItem.State = SelectionEnabledState.Closed;
                 myListBoxItem.UpdateVisualState(true);
             }
         }
     }));
 }
Ejemplo n.º 5
0
 private void CloseSelection()
 {
     this.Dispatcher.BeginInvoke((Action)(() =>
     {
         for (int index = 0; index < this.Items.Count; ++index)
         {
             MyListBoxItem myListBoxItem = (MyListBoxItem)this.ItemContainerGenerator.ContainerFromIndex(index);
             if (myListBoxItem != null)
             {
                 myListBoxItem.State = SelectionEnabledState.Closed;
                 myListBoxItem.UpdateVisualState(true);
             }
         }
     }));
 }
Ejemplo n.º 6
0
        private static void OnIsSelectedPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            MyListBoxItem   myListBoxItem = (MyListBoxItem)obj;
            RoutedEventArgs e1            = new RoutedEventArgs();
            // ISSUE: explicit reference operation
            bool newValue = (bool)e.NewValue;

            if (newValue)
            {
                myListBoxItem.OnSelected(e1);
            }
            else
            {
                myListBoxItem.OnUnselected(e1);
            }
            if (myListBoxItem._parent == null || myListBoxItem._isBeingVirtualized)
            {
                return;
            }
            if (newValue)
            {
                myListBoxItem._parent.SelectedItems.Add(((ContentControl)myListBoxItem).Content);
                if (!myListBoxItem._canTriggerSelectionChanged)
                {
                    return;
                }
                myListBoxItem._parent.OnSelectionChanged((IList) new object[0], (IList) new object[1]
                {
                    ((ContentControl)myListBoxItem).Content
                });
            }
            else
            {
                myListBoxItem._parent.SelectedItems.Remove(((ContentControl)myListBoxItem).Content);
                if (!myListBoxItem._canTriggerSelectionChanged)
                {
                    return;
                }
                myListBoxItem._parent.OnSelectionChanged((IList) new object[1]
                {
                    ((ContentControl)myListBoxItem).Content
                }, (IList) new object[0]);
            }
        }