Inheritance: FrameworkElement
        public BorderSelectionLogic(MultiSelectTreeView treeView, Border selectionBorder, ScrollViewer scrollViewer, ItemsPresenter content, IEnumerable<MultiSelectTreeViewItem> items)
        {
            if (treeView == null)
            {
                throw new ArgumentNullException("treeView");
            }
            if (selectionBorder == null)
            {
                throw new ArgumentNullException("selectionBorder");
            }
            if (scrollViewer == null)
            {
                throw new ArgumentNullException("scrollViewer");
            }
            if (content == null)
            {
                throw new ArgumentNullException("content");
            }
            if (items == null)
            {
                throw new ArgumentNullException("items");
            }

            this.treeView = treeView;
            this.border = selectionBorder;
            this.scrollViewer = scrollViewer;
            this.content = content;
            this.items = items;

            treeView.MouseDown += OnMouseDown;
            treeView.MouseMove += OnMouseMove;
            treeView.MouseUp += OnMouseUp;
            treeView.KeyDown += OnKeyDown;
            treeView.KeyUp += OnKeyUp;
        }
Exemple #2
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _presenter = base.GetTemplateChild("ItemsPresenter") as ItemsPresenter;
            _presenter.LayoutUpdated += new EventHandler(ItemsPresenter_LayoutUpdated);
        }
        public override void OnApplyTemplate()
        {
            m_ItemsPresenter = GetTemplateChild("ItemsPresenter") as ItemsPresenter;
            m_Pointer = GetTemplateChild("Pointer") as FrameworkElement;
            if (m_Pointer != null)
            {
                m_Pointer.RenderTransform = m_Translation = new TranslateTransform();

                Storyboard.SetTarget(m_Animation, m_Pointer);
                Storyboard.SetTargetProperty(m_Animation, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.Y)"));
            }

            base.OnApplyTemplate();
            AnimateToSelectedIndex();
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _Items = Template.FindName("items", this) as ItemsPresenter;
            _Indexs = Template.FindName("indexs", this) as ListBox;
            if (_Indexs != null)
            {
                _Indexs.SelectionChanged += OnIndexsSelectionChanged;
            }
            _Timer = new DispatcherTimer();
            _Timer.Interval = TimeSpan.FromSeconds(4);
            _Timer.Tick += OnTimerTick;
            _Timer.Start();

        }
Exemple #5
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                _popup = GetTemplateChild("PART_Popup") as Popup;
                _mask = GetTemplateChild("PART_Mask") as FrameworkElement;
                _background = GetTemplateChild("Part_Background") as FrameworkElement;
                _root = GetTemplateChild("PART_Root") as Grid;
                _canvas = GetTemplateChild("PART_Canvas") as Canvas;
                _itemsPresenter = GetTemplateChild("PART_ItemsPresenter") as ItemsPresenter;

                _popup.Opened += Popup_Opened;
                _popup.Closed += Popup_Closed;
                _mask.MouseLeftButtonDown += Mask_MouseButtonDown;
                _mask.MouseRightButtonDown += Mask_MouseButtonDown;
            }
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.footerTrayPanel = (Panel)GetTemplateChild("PART_FooterTrayPanel");
            this.buttonsItemsPresenter = (ItemsPresenter)GetTemplateChild("PART_ButtonsPresenter");
            this.dataGrid = (DataGrid)GetTemplateChild("PART_DataGrid");
            this.resizeGripper = (FrameworkElement)GetTemplateChild("PART_ResizeGripper");

            if (this.dataGrid == null)
            {
                throw new Exception("ControlTemplate does not contain PART_DataGrid!");
            }
            if (this.footerTrayPanel == null)
            {
                throw new Exception("ControlTemplate does not contain PART_FooterTrayPanel!");
            }
            if (this.buttonsItemsPresenter == null)
            {
                throw new Exception("ControlTemplate does not contain PART_ButtonsPresenter!");
            }
            if (this.resizeGripper == null)
            {
                throw new Exception("ControlTemplate does not contain PART_ResizeGripper!");
            }

            this.dataGrid.CanUserReorderColumns = true;
            this.dataGrid.CanUserResizeColumns = true;
            this.dataGrid.CanUserSortColumns = true;
            this.dataGrid.HeadersVisibility = DataGridHeadersVisibility.Column;            
            this.dataGrid.AutoGenerateColumns = false;
#if(!SILVERLIGHT)
            this.dataGrid.CanUserAddRows = false;
#endif
            var itemsSourceBinding = new Binding("ItemsSource") { Source = this };
            this.dataGrid.SetBinding(DataGrid.ItemsSourceProperty, itemsSourceBinding);

            this.resizeGripper.MouseLeftButtonDown += this.resizeGripper_MouseLeftButtonDown;
            this.resizeGripper.MouseMove += this.resizeGripper_MouseMove;
            this.resizeGripper.MouseLeftButtonUp += this.resizeGripper_MouseLeftButtonUp;

            this.buttonsItemsPresenter.SizeChanged += this.buttonsItemsPresenter_SizeChanged;
        }
Exemple #7
0
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal processes (such as a rebuilding layout pass) call <see cref="M:System.Windows.Controls.Control.ApplyTemplate"/>.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.elementRoot = GetTemplateChild(ElementRootName) as FrameworkElement;
            this.itemsHost = GetTemplateChild(ItemsPresenterName) as ItemsPresenter;
            this.expander = GetTemplateChild(ExpanderName) as ToggleButton;

            if (this.expander != null)
            {
                this.expander.IsEnabled = this.HasItems;
                this.expander.IsChecked = false;
                this.expander.Checked += this.ToggleButton_CheckChange;
                this.expander.Unchecked += this.ToggleButton_CheckChange;
            }
        }
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     _itemsPresenter = (ItemsPresenter)GetTemplateChild(ItemsHostName);
     _headerPresenter = (ContentPresenter)GetTemplateChild(HeaderPresenterName);
     SyncProperties();
 }
Exemple #9
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (_resizeThumb != null)
            {
                _resizeThumb.DragStarted -= new DragStartedEventHandler(OnPopupResizeStarted);
                _resizeThumb.DragDelta -= new DragDeltaEventHandler(OnPopupResize);
            }

            _resizeThumb = GetTemplateChild(ResizeThumbTemplatePartName) as Thumb;
            if (_resizeThumb != null)
            {
                _resizeThumb.DragStarted += new DragStartedEventHandler(OnPopupResizeStarted);
                _resizeThumb.DragDelta += new DragDeltaEventHandler(OnPopupResize);
            }

            _itemsPresenter = GetTemplateChild(ItemsPresenterTemplatePartName) as ItemsPresenter;

            if (_popup != null)
            {
                _popup.Opened -= new EventHandler(OnPopupOpened);
                _popup.CustomPopupPlacementCallback -= new CustomPopupPlacementCallback(PlacePopup);
            }

            _popup = GetTemplateChild(PopupTemplatePartName) as Popup;

            if (_popup != null)
            {
                _popup.Opened += new EventHandler(OnPopupOpened);
                _popup.CustomPopupPlacementCallback += new CustomPopupPlacementCallback(PlacePopup);
            }

            _sideBarBorder = GetTemplateChild(SideBarBorderTemplatePartName) as UIElement;

            PropertyHelper.TransferProperty(this, ContextMenuProperty);   // Coerce to get a default ContextMenu if none has been specified.
            PropertyHelper.TransferProperty(this, RibbonControlService.CanAddToQuickAccessToolBarDirectlyProperty);

            ItemContainerGenerator.StatusChanged += new EventHandler(OnItemContainerGeneratorStatusChanged);

            _submenuScrollViewer = GetTemplateChild(SubMenuScrollViewerTemplatePartName) as ScrollViewer;
            if (_submenuScrollViewer != null)
            {
                KeyTipService.SetCanClipKeyTip(_submenuScrollViewer, false);
            }
        }
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     ItemsPresenter = (ItemsPresenter) GetTemplateChild("ItemsPresenter");
 }
 void IAddChild.AddChild(object value)
 {
     if (value is ItemsPresenter)
         ItemsHost = (ItemsPresenter)value;
     else if (value is ContentPresenter)
         Header = (ContentPresenter)value;
 }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            itemsPresenter = (ItemsPresenter) GetTemplateChild("ItemsPresenter");
            itemsPresenter.LayoutUpdated += ItemsPresenterLayoutUpdated;
        }
        /// <summary>
        /// Builds the visual tree for the Accordion control when a 
        /// new template is applied.
        /// </summary>
        public override void OnApplyTemplate()
        {
            ItemsControlHelper.OnApplyTemplate();
            base.OnApplyTemplate();
            Interaction.OnApplyTemplateBase();

            _presenter = base.GetTemplateChild(Presenter) as ItemsPresenter;
        }
Exemple #14
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            // remove any old handlers
            if (_filterMenuButton != null)
            {
                Debug.Assert(_filterMenuButton.ItemContainerGenerator != null);
                _filterMenuButton.ItemContainerGenerator.StatusChanged -= OnFilterButtonItemContainerGeneratorStatusChanged;
            }

            _filterMenuButton = this.Template.FindName(_filterMenuButtonTemplatePartName, this) as RibbonMenuButton;

            if (_filterMenuButton != null)
            {
                Debug.Assert(_filterMenuButton.ItemContainerGenerator != null);
                _filterMenuButton.ItemContainerGenerator.StatusChanged += new EventHandler(OnFilterButtonItemContainerGeneratorStatusChanged);
                Binding itemsSourceBinding = new Binding() { Source = this._categoryFilters };
                _filterMenuButton.SetBinding(RibbonMenuButton.ItemsSourceProperty, itemsSourceBinding);

                _filterMenuButton.Loaded += new RoutedEventHandler(filterMenuButton_Loaded);
            }

            _itemsPresenter = (ItemsPresenter)GetTemplateChild(ItemsHostName);
            _filterContentPane = GetTemplateChild(FilterContentPaneTemplatePartName) as ContentPresenter;
            _scrollViewer = GetTemplateChild(RibbonGallery.ScrollViewerTemplatePartName) as ScrollViewer;
        }
Exemple #15
0
		internal void SetItemsPresenter (ItemsPresenter presenter)
		{
			if (_presenter != null) {
				_presenter._elementRoot.Children.Clear ();
			}
			_presenter = presenter;
			AddItemsToPresenter (new GeneratorPosition (-1, 1), Items.Count);
		}
Exemple #16
0
        public BorderSelectionLogic(MultiSelectTreeView treeView, Border selectionBorder, ScrollViewer scrollViewer, ItemsPresenter content, IEnumerable <MultiSelectTreeViewItem> items)
        {
            if (treeView == null)
            {
                throw new ArgumentNullException("treeView");
            }
            if (selectionBorder == null)
            {
                throw new ArgumentNullException("selectionBorder");
            }
            if (scrollViewer == null)
            {
                throw new ArgumentNullException("scrollViewer");
            }
            if (content == null)
            {
                throw new ArgumentNullException("content");
            }
            if (items == null)
            {
                throw new ArgumentNullException("items");
            }

            this.treeView     = treeView;
            this.border       = selectionBorder;
            this.scrollViewer = scrollViewer;
            this.content      = content;
            this.items        = items;

            treeView.MouseDown += OnMouseDown;
            treeView.MouseMove += OnMouseMove;
            treeView.MouseUp   += OnMouseUp;
            treeView.KeyDown   += OnKeyDown;
            treeView.KeyUp     += OnKeyUp;
        }
Exemple #17
0
		internal override UIElement GetDefaultTemplate ()
		{
			ItemsPresenter presenter = _presenter;
			if (presenter == null) {
				presenter = new ItemsPresenter ();
				presenter.TemplateOwner = this;
			}
			return presenter;
		}
 /// <summary>
 /// When overridden in a derived class, is invoked whenever application code or internal processes (such as a rebuilding layout pass) call <see cref="M:System.Windows.Controls.Control.ApplyTemplate"/>. In simplest terms, this means the method is called just before a UI element displays in an application. For more information, see Remarks.
 /// </summary>
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate ();
     _itemsPresenter = GetTemplateChild ( "ItemsPresenter" ) as ItemsPresenter;
     _templateApplied = true;
     LayoutUpdated += ApplyTemplateLayoutUpdated;
 }
Exemple #19
0
        // Property invalidation callback invoked when TemplateProperty is invalidated
        private static void OnTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ItemsPresenter ip = (ItemsPresenter)d;

            StyleHelper.UpdateTemplateCache(ip, (FrameworkTemplate)e.OldValue, (FrameworkTemplate)e.NewValue, TemplateProperty);
        }
Exemple #20
0
        private void DiagramItemsPresenter_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            var itemsPresenter = sender as ItemsPresenter;
            if (itemsPresenter != null)
            {
                DiagramItemsPresenter = itemsPresenter;

            }
        }
        /// <summary>
        /// Gets the template parts and sets event handlers.
        /// </summary>
        public override void OnApplyTemplate()
        {
            if (_expanderPanel != null)
            {
                _expanderPanel.Tap -= OnExpanderPanelTap;
            }

            base.OnApplyTemplate();

            _expanderPanel = base.GetTemplateChild(ExpanderPanel) as Grid;
            _expandedStateAnimation = (base.GetTemplateChild(ExpandedState) as VisualState).Storyboard.Children[0] as DoubleAnimation;
            _expandedToCollapsedFrame = base.GetTemplateChild(ExpandedToCollapsedKeyFrame) as EasingDoubleKeyFrame;
            _collapsedToExpandedFrame = base.GetTemplateChild(CollapsedToExpandedKeyFrame) as EasingDoubleKeyFrame;
            _itemsCanvas = base.GetTemplateChild("ItemsCanvas") as Canvas;
            _presenter = base.GetTemplateChild(Presenter) as ItemsPresenter;
            _presenter.SizeChanged += OnPresenterSizeChanged;
            
            if (_expanderPanel != null)
            {
                _expanderPanel.Tap += OnExpanderPanelTap;
            }

            UpdateVisualState(false);
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _txtBox = Template.FindName("PART_EditableTextBox", this) as TextBox;
            if (_txtBox != null)
            {
                _txtBox.GotFocus += new RoutedEventHandler(_txtBox_GotFocus);
                _txtBox.LostFocus += new RoutedEventHandler(_txtBox_LostFocus);
                _txtBox.TextChanged += new TextChangedEventHandler(_txtBox_TextChanged);
            }
            _itemsPresenter = Template.FindName("ItemsPresenter", this) as ItemsPresenter;
            _popup = Template.FindName("Popup", this) as Popup;
            if (_popup != null)
            {
                _popup.MouseMove += new MouseEventHandler(_popup_MouseMove);
                _popup.MouseEnter += new MouseEventHandler(_popup_MouseEnter);
            }
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (part_contentHost != null)
                part_contentHost.SizeChanged += part_contentHostSizechanged;
            part_contentHost = GetTemplateChild(NavigationPaneExpanderParts.PART_ContentHost) as ItemsPresenter;
            if(part_contentHost != null)
                part_contentHost.SizeChanged += part_contentHostSizechanged;

            part_contentHostContainerExpanded = GetTemplateChild(NavigationPaneExpanderParts.PART_ContentHostContainerExpanded) as Border;
            part_contentHostContainerUnexpanded = GetTemplateChild(NavigationPaneExpanderParts.PART_ContentHostContainerUnexpanded) as Border;

            part_headerHost = GetTemplateChild(NavigationPaneExpanderParts.PART_HeaderHost) as Border;
            part_headerHostMinimized = GetTemplateChild(NavigationPaneExpanderParts.PART_HeaderHostMinimized) as Border;

            part_closeButton = GetTemplateChild(NavigationPaneExpanderParts.PART_CloseButton) as ToggleButton;
            if(part_closeButton != null)
                part_closeButton.Click += new RoutedEventHandler(part_closeButton_Click);

            InitPopup();

            // check minimizeHelper because on blend when you try to edit the style BeginInit() is not already called
            // or is not called at all !! ?? Anyways... check to avoid use of null value reference
            if (minimizeHelper != null)
                minimizeHelper.Init(GetTemplateChild(NavigationPaneExpanderParts.PART_ResizeThumb) as Thumb,
                    GetTemplateChild(NavigationPaneExpanderParts.PART_MininizedSizeProvider) as FrameworkElement, part_contentHost);
        }
 void ItemsPresenterLayoutUpdated(object sender, EventArgs e)
 {
     if (itemsPresenter != null)
         itemsPresenter.LayoutUpdated -= ItemsPresenterLayoutUpdated;
     itemsPresenter = (ItemsPresenter) GetTemplateChild("ItemsPresenter");
     UpdateMeasure();
 }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            PART_ScrollViewer = this.FindVisualDescendant<ScrollViewer>(descendantName: "PART_ScrollViewer");
            
            // search in content of content controls (view box is most likely inside scroll viewer)
            PART_ViewBox = this.FindVisualDescendant<Viewbox>(descendantName: "PART_ViewBox");

            ItemsPresenter = this.FindVisualDescendant<ItemsPresenter>();

            ItemsPresenter.ApplyTemplate();

            ItemsPanel = ItemsPresenter.FindVisualDescendant<Panel>();
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            ItemsPresenter = this.FindVisualDescendant<ItemsPresenter>();
        }
        /// <summary>
        /// Builds the visual tree for the control when a new template is applied.
        /// </summary>
        public override void OnApplyTemplate()
        {
            // Unhook from old elements
            if (null != _itemsPresenterHostParent)
            {
                _itemsPresenterHostParent.SizeChanged -= HandleItemsPresenterHostParentSizeChanged;
            }
            _storyboard.Stop();

            base.OnApplyTemplate();

            // Hook up to new elements
            _itemsPresenterPart = GetTemplateChild(ItemsPresenterPartName) as ItemsPresenter;
            _itemsPresenterTranslateTransformPart = GetTemplateChild(ItemsPresenterTranslateTransformPartName) as TranslateTransform;
            _itemsPresenterHostPart = GetTemplateChild(ItemsPresenterHostPartName) as Canvas;
            _fullModePopupPart = GetTemplateChild(FullModePopupPartName) as Popup;
            _fullModeSelectorPart = GetTemplateChild(FullModeSelectorPartName) as Selector;
            _itemsPresenterHostParent = (null != _itemsPresenterHostPart) ? _itemsPresenterHostPart.Parent as FrameworkElement : null;
            if (null != _itemsPresenterHostParent)
            {
                _itemsPresenterHostParent.SizeChanged += HandleItemsPresenterHostParentSizeChanged;
            }
            if (null != _itemsPresenterHostPart)
            {
                Storyboard.SetTarget(_heightAnimation, _itemsPresenterHostPart);
                if (!_storyboard.Children.Contains(_heightAnimation))
                {
                    _storyboard.Children.Add(_heightAnimation);
                }
            }
            else
            {
                if (_storyboard.Children.Contains(_heightAnimation))
                {
                    _storyboard.Children.Remove(_heightAnimation);
                }
            }
            if (null != _itemsPresenterTranslateTransformPart)
            {
                Storyboard.SetTarget(_translateAnimation, _itemsPresenterTranslateTransformPart);
                if (!_storyboard.Children.Contains(_translateAnimation))
                {
                    _storyboard.Children.Add(_translateAnimation);
                }
            }
            else
            {
                if (_storyboard.Children.Contains(_translateAnimation))
                {
                    _storyboard.Children.Remove(_translateAnimation);
                }
            }
            if (null != _fullModePopupPart)
            {
                UIElement child = _fullModePopupPart.Child;
                _fullModePopupPart.Child = null;
                _fullModePopupPart = new Popup();
                _fullModePopupPart.Child = child;
            }
            SetBinding(ShadowItemTemplateProperty, new Binding("ItemTemplate") { Source = this });

            // Commit deferred SelectedIndex (if any)
            if (-1 != _deferredSelectedIndex)
            {
                SelectedIndex = _deferredSelectedIndex;
                _deferredSelectedIndex = -1;
            }

            // Go to current state(s)
            GoToStates(false);
        }
Exemple #28
0
        /// <summary>
        /// Gets the template parts from the template.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.itemsPresenter = (ItemsPresenter)this.GetTemplateChild(ConceptListBox.ElementItemsPresenter);
            if (this.itemsPresenter != null)
            {
                this.itemsPresenter.Loaded += new RoutedEventHandler(this.ItemsPresenter_Loaded);
            }

            this.scrollViewer = (ScrollViewer)this.GetTemplateChild(ConceptListBox.ElementScrollViewer);
        }
Exemple #29
0
        // Token: 0x0600545F RID: 21599 RVA: 0x00175B34 File Offset: 0x00173D34
        internal void HookupScrollingComponents()
        {
            ScrollViewer scrollViewer = base.TemplatedParent as ScrollViewer;

            if (scrollViewer != null)
            {
                IScrollInfo scrollInfo = null;
                if (this.CanContentScroll)
                {
                    scrollInfo = (base.Content as IScrollInfo);
                    if (scrollInfo == null)
                    {
                        Visual visual = base.Content as Visual;
                        if (visual != null)
                        {
                            ItemsPresenter itemsPresenter = visual as ItemsPresenter;
                            if (itemsPresenter == null)
                            {
                                FrameworkElement frameworkElement = scrollViewer.TemplatedParent as FrameworkElement;
                                if (frameworkElement != null)
                                {
                                    itemsPresenter = (frameworkElement.GetTemplateChild("ItemsPresenter") as ItemsPresenter);
                                }
                            }
                            if (itemsPresenter != null)
                            {
                                itemsPresenter.ApplyTemplate();
                                int childrenCount = VisualTreeHelper.GetChildrenCount(itemsPresenter);
                                if (childrenCount > 0)
                                {
                                    scrollInfo = (VisualTreeHelper.GetChild(itemsPresenter, 0) as IScrollInfo);
                                }
                            }
                        }
                    }
                }
                if (scrollInfo == null)
                {
                    scrollInfo = this;
                    this.EnsureScrollData();
                }
                if (scrollInfo != this._scrollInfo && this._scrollInfo != null)
                {
                    if (this.IsScrollClient)
                    {
                        this._scrollData = null;
                    }
                    else
                    {
                        this._scrollInfo.ScrollOwner = null;
                    }
                }
                if (scrollInfo != null)
                {
                    this._scrollInfo        = scrollInfo;
                    scrollInfo.ScrollOwner  = scrollViewer;
                    scrollViewer.ScrollInfo = scrollInfo;
                    return;
                }
            }
            else if (this._scrollInfo != null)
            {
                if (this._scrollInfo.ScrollOwner != null)
                {
                    this._scrollInfo.ScrollOwner.ScrollInfo = null;
                }
                this._scrollInfo.ScrollOwner = null;
                this._scrollInfo             = null;
                this._scrollData             = null;
            }
        }
        /// <summary>
        /// Builds the visual tree for the control when a new template is applied.
        /// </summary>
        public override void OnApplyTemplate()
        {
            // Unhook from old elements
            if (null != _itemsPresenterHostParent)
            {
                _itemsPresenterHostParent.SizeChanged -= HandleItemsPresenterHostParentSizeChanged;
            }
            _storyboard.Stop();

            base.OnApplyTemplate();

            // Hook up to new elements
            _itemsPresenterPart = GetTemplateChild(ItemsPresenterPartName) as ItemsPresenter;
            _itemsPresenterTranslateTransformPart = GetTemplateChild(ItemsPresenterTranslateTransformPartName) as TranslateTransform;
            _itemsPresenterHostPart = GetTemplateChild(ItemsPresenterHostPartName) as Canvas;
            _itemsPresenterHostParent = (null != _itemsPresenterHostPart) ? _itemsPresenterHostPart.Parent as FrameworkElement : null;
            _multipleSelectionModeSummary = GetTemplateChild(MultipleSelectionModeSummaryPartName) as TextBlock;
            _border = GetTemplateChild(BorderPartName) as Border;

            if (null != _itemsPresenterHostParent)
            {
                _itemsPresenterHostParent.SizeChanged += HandleItemsPresenterHostParentSizeChanged;
            }
            if (null != _itemsPresenterHostPart)
            {
                Storyboard.SetTarget(_heightAnimation, _itemsPresenterHostPart);
                if (!_storyboard.Children.Contains(_heightAnimation))
                {
                    _storyboard.Children.Add(_heightAnimation);
                }
            }
            else
            {
                if (_storyboard.Children.Contains(_heightAnimation))
                {
                    _storyboard.Children.Remove(_heightAnimation);
                }
            }
            if (null != _itemsPresenterTranslateTransformPart)
            {
                Storyboard.SetTarget(_translateAnimation, _itemsPresenterTranslateTransformPart);
                if (!_storyboard.Children.Contains(_translateAnimation))
                {
                    _storyboard.Children.Add(_translateAnimation);
                }
            }
            else
            {
                if (_storyboard.Children.Contains(_translateAnimation))
                {
                    _storyboard.Children.Remove(_translateAnimation);
                }
            }
            
            SetBinding(ShadowItemTemplateProperty, new Binding("ItemTemplate") { Source = this });


            // Commit deferred SelectedIndex (if any)
            if (-1 != _deferredSelectedIndex)
            {
                SelectedIndex = _deferredSelectedIndex;
                _deferredSelectedIndex = -1;
            }

            OnSelectionModeChanged(SelectionMode);
            OnSelectedItemsChanged(SelectedItems, SelectedItems);
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _itemsPanel = GetTemplateChild(ItemsPanelHostProperty) as Panel;
            _itemsPresenter = GetTemplateChild(ItemsPresenterProperty) as ItemsPresenter;
            _itemsPanel.Background = new SolidColorBrush(Colors.Brown);
            UpdateItemTemplate();
            UpdateVisualStates(true);
            if (null != _deferredSelectedItem) {
                ((_deferredSelectedItem as MultipleButtonItem).Content as RadioButton).IsChecked = true;
                _deferredSelectedItem = null;

                //UpdateMenuItem(SelectedItem as MultipleButtonItem, true);
            }
        }