UpdateVisualState() приватный Метод

Updates the visual state.
private UpdateVisualState ( bool useTransitions ) : void
useTransitions bool /// Indicates whether visual transitions should be used. ///
Результат void
Пример #1
0
        /// <summary>
        /// Triggers the visual state changes and visual transitions
        /// to close the list out of selection mode.
        /// </summary>
        private void CloseSelection()
        {
            IList <WeakReference> items = ItemsControlExtensions.GetItemsInViewPort(this);

            //Only animate the containers in the view port.
            foreach (var i in items)
            {
                MultiselectItem item = (MultiselectItem)(((WeakReference)i).Target);
                item.State = SelectionEnabledState.Closed;
                item.UpdateVisualState(true);
            }

            Dispatcher.BeginInvoke(() =>
            {
                for (int j = 0; j < this.Items.Count; j++)
                {
                    MultiselectItem item = (MultiselectItem)ItemContainerGenerator.ContainerFromIndex(j);
                    if (item != null)
                    {
                        item.State = SelectionEnabledState.Closed;
                        item.UpdateVisualState(false);
                    }
                }
            });
        }
Пример #2
0
        /// <summary>
        /// Resets new or reused item containers appropiately.
        /// </summary>
        /// <param name="element"></param>
        /// <param name="item"></param>
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);

            MultiselectItem container = (MultiselectItem)element;

            container.Style = this.ItemContainerStyle;
            container._isBeingVirtualized = true;

            //Select or unselect item containers to put or clear checkmarks.
            container.IsSelected = SelectedItems.Contains(item);

            //Open or close item containers depending on the selection mode.
            container.State = IsSelectionEnabled ? SelectionEnabledState.Opened : SelectionEnabledState.Closed;

            container.UpdateVisualState(false);
            container._isBeingVirtualized = false;
        }