Inheritance: System.Windows.Controls.ItemsControl
 public void InitializeComponent() {
     if (_contentLoaded) {
         return;
     }
     _contentLoaded = true;
     System.Windows.Application.LoadComponent(this, new System.Uri("/PhoneToolkitSample;component/Samples/MultiselectListSample.xaml", System.UriKind.Relative));
     this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
     this.ContentPanel = ((System.Windows.Controls.Grid)(this.FindName("ContentPanel")));
     this.EmailList = ((Microsoft.Phone.Controls.MultiselectList)(this.FindName("EmailList")));
     this.appbar_button1 = ((Microsoft.Phone.Shell.ApplicationBarIconButton)(this.FindName("appbar_button1")));
 }
Exemple #2
0
 public void InitializeComponent()
 {
     if (_contentLoaded)
     {
         return;
     }
     _contentLoaded = true;
     System.Windows.Application.LoadComponent(this, new System.Uri("/TimeSheet;component/MainPage.xaml", System.UriKind.Relative));
     this.LayoutRoot   = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
     this.PivotMain    = ((Microsoft.Phone.Controls.Pivot)(this.FindName("PivotMain")));
     this.LongTasks    = ((Microsoft.Phone.Controls.MultiselectList)(this.FindName("LongTasks")));
     this.ContentPanel = ((System.Windows.Controls.Grid)(this.FindName("ContentPanel")));
 }
        /// <summary>
        /// Opens or closes the selection mode accordingly.
        /// If closing, it unselects any selected item.
        /// Finally, it fires up an IsSelectionEnabledChanged event.
        /// </summary>
        /// <param name="obj">The dependency object.</param>
        /// <param name="e">The event information.</param>
        private static void OnIsSelectionEnabledPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            MultiselectList target = (MultiselectList)obj;

            if ((bool)e.NewValue)
            {
                target.OpenSelection();
            }
            else
            {
                if (target.SelectedItems.Count > 0)
                {
                    IList removedItems = new List <object>();

                    //All the selected items will be unselected.
                    foreach (object item in target.SelectedItems)
                    {
                        removedItems.Add(item);
                    }

                    //Unselect the containers that are not virtualized.
                    for (int k = 0; k < target.Items.Count && target.SelectedItems.Count > 0; k++)
                    {
                        MultiselectItem item = (MultiselectItem)target.ItemContainerGenerator.ContainerFromIndex(k);
                        if (item != null)
                        {
                            if (item.IsSelected == true)
                            {
                                item._canTriggerSelectionChanged = false;
                                item.IsSelected = false;
                                item._canTriggerSelectionChanged = true;
                            }
                        }
                    }

                    //Clear the selected items and trigger event.
                    target.SelectedItems.Clear();
                    target.OnSelectionChanged(removedItems, new object[0]);
                }

                target.CloseSelection();
            }

            var handler = target.IsSelectionEnabledChanged;

            if (handler != null)
            {
                handler(obj, e);
            }
        }
Exemple #4
0
        /// <summary>
        /// Gets the template parts and sets event handlers.
        /// </summary>
        public override void OnApplyTemplate()
        {
            _parent = this.GetParentByType<MultiselectList>();                

            if (_innerHintPanel != null)
            {
                _innerHintPanel.ManipulationStarted -= HintPanel_ManipulationStarted;
                _innerHintPanel.ManipulationDelta -= HintPanel_ManipulationDelta;
                _innerHintPanel.ManipulationCompleted -= HintPanel_ManipulationCompleted;
            }

            if (_outterHintPanel != null)
            {
                _outterHintPanel.ManipulationStarted -= HintPanel_ManipulationStarted;
                _outterHintPanel.ManipulationDelta -= HintPanel_ManipulationDelta;
                _outterHintPanel.ManipulationCompleted -= HintPanel_ManipulationCompleted;
            }

            if (_outterCover != null)
            {
                _outterCover.Tap -= Cover_Tap;
            }

            _innerHintPanel = base.GetTemplateChild(InnerHintPanel) as Rectangle;
            _outterHintPanel = base.GetTemplateChild(OutterHintPanel) as Rectangle;
            _outterCover = base.GetTemplateChild(OutterCover) as Grid;
            _infoPresenter = base.GetTemplateChild(InfoPresenter) as ContentControl;
           
            base.OnApplyTemplate();

            if (_innerHintPanel != null)
            {
                _innerHintPanel.ManipulationStarted += HintPanel_ManipulationStarted;
                _innerHintPanel.ManipulationDelta += HintPanel_ManipulationDelta;
                _innerHintPanel.ManipulationCompleted += HintPanel_ManipulationCompleted;
            }

            if (_outterHintPanel != null)
            {
                _outterHintPanel.ManipulationStarted += HintPanel_ManipulationStarted;
                _outterHintPanel.ManipulationDelta += HintPanel_ManipulationDelta;
                _outterHintPanel.ManipulationCompleted += HintPanel_ManipulationCompleted;
            }


            if (_outterCover != null)
            {
                _outterCover.Tap += Cover_Tap;
            }

            if (ContentInfo == null && _parent != null)
            {
                if (_parent.ItemInfoTemplate != null)
                {
                    _infoPresenter.ContentTemplate = _parent.ItemInfoTemplate;
                    Binding infoBinding = new Binding();
                    this.SetBinding(ContentInfoProperty, infoBinding);
                }
            }

            if (_outterHintPanel != null)
            {
                if (double.IsNaN(HintPanelHeight))
                {
                    _outterHintPanel.VerticalAlignment = VerticalAlignment.Stretch;
                }
                else
                {
                    _outterHintPanel.VerticalAlignment = VerticalAlignment.Top;                   
                }
            }

            if (_innerHintPanel != null)
            {
                if (double.IsNaN(HintPanelHeight))
                {
                    _innerHintPanel.VerticalAlignment = VerticalAlignment.Stretch;
                }
                else
                {
                    _innerHintPanel.VerticalAlignment = VerticalAlignment.Top;
                }
            }

            UpdateVisualState(false);
        }
        /// <summary>
        /// Gets the template parts and sets event handlers.
        /// </summary>
        public override void OnApplyTemplate()
        {
            _parent = this.GetParentByType <MultiselectList>();

            if (_innerHintPanel != null)
            {
                _innerHintPanel.ManipulationStarted   -= HintPanel_ManipulationStarted;
                _innerHintPanel.ManipulationDelta     -= HintPanel_ManipulationDelta;
                _innerHintPanel.ManipulationCompleted -= HintPanel_ManipulationCompleted;
            }

            if (_outterHintPanel != null)
            {
                _outterHintPanel.ManipulationStarted   -= HintPanel_ManipulationStarted;
                _outterHintPanel.ManipulationDelta     -= HintPanel_ManipulationDelta;
                _outterHintPanel.ManipulationCompleted -= HintPanel_ManipulationCompleted;
            }

            if (_outterCover != null)
            {
                _outterCover.Tap -= Cover_Tap;
            }

            _innerHintPanel  = base.GetTemplateChild(InnerHintPanel) as Rectangle;
            _outterHintPanel = base.GetTemplateChild(OutterHintPanel) as Rectangle;
            _outterCover     = base.GetTemplateChild(OutterCover) as Grid;
            _infoPresenter   = base.GetTemplateChild(InfoPresenter) as ContentControl;

            base.OnApplyTemplate();

            if (_innerHintPanel != null)
            {
                _innerHintPanel.ManipulationStarted   += HintPanel_ManipulationStarted;
                _innerHintPanel.ManipulationDelta     += HintPanel_ManipulationDelta;
                _innerHintPanel.ManipulationCompleted += HintPanel_ManipulationCompleted;
            }

            if (_outterHintPanel != null)
            {
                _outterHintPanel.ManipulationStarted   += HintPanel_ManipulationStarted;
                _outterHintPanel.ManipulationDelta     += HintPanel_ManipulationDelta;
                _outterHintPanel.ManipulationCompleted += HintPanel_ManipulationCompleted;
            }


            if (_outterCover != null)
            {
                _outterCover.Tap += Cover_Tap;
            }

            if (ContentInfo == null && _parent != null)
            {
                if (_parent.ItemInfoTemplate != null)
                {
                    _infoPresenter.ContentTemplate = _parent.ItemInfoTemplate;
                    Binding infoBinding = new Binding();
                    this.SetBinding(ContentInfoProperty, infoBinding);
                }
            }

            if (_outterHintPanel != null)
            {
                if (double.IsNaN(HintPanelHeight))
                {
                    _outterHintPanel.VerticalAlignment = VerticalAlignment.Stretch;
                }
                else
                {
                    _outterHintPanel.VerticalAlignment = VerticalAlignment.Top;
                }
            }

            if (_innerHintPanel != null)
            {
                if (double.IsNaN(HintPanelHeight))
                {
                    _innerHintPanel.VerticalAlignment = VerticalAlignment.Stretch;
                }
                else
                {
                    _innerHintPanel.VerticalAlignment = VerticalAlignment.Top;
                }
            }

            UpdateVisualState(false);
        }
        /// <summary>
        /// Keep track of the currently displayed Multiselect List at each change
        /// of the Pivot control.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pivot_LoadingPivotItem(object sender, PivotItemEventArgs e)
        {
            if(CurrentMultiselectList != null)
                CurrentMultiselectList.IsSelectionEnabled = false;

            if (e.Item == DownloadsPivotItem)
            {
                CurrentMultiselectList = DownloadsMultiselectList;
            }
            else if (e.Item == ArchivePivotItem)
            {
                CurrentMultiselectList = ArchiveMultiselectList;
            }
        }