コード例 #1
0
        internal NativeListViewItem GetItem(
            object item)
        {
            NativeListViewItem customItem;

            if (!this._customItemMap.TryGetValue(item, out customItem))
            {
                customItem = new NativeListViewItem(item);
                this._customItemMap.Add(item, customItem);
            }
            return(customItem);
        }
コード例 #2
0
        public object this[int index]
        {
            get
            {
                object             item       = this._source[index];
                NativeListViewItem customItem = GetItem(item);
                return(customItem);
            }

            set
            {
                throw new NotImplementedException();
            }
        }
コード例 #3
0
        private IList <NativeListViewItem> MapCustomItems(
            IList changeList)
        {
            if (changeList == null)
            {
                return(null);
            }

            List <NativeListViewItem> list = new List <NativeListViewItem>(changeList.Count);

            foreach (object item in changeList)
            {
                NativeListViewItem customItem = GetItem(item);
                list.Add(customItem);
            }

            return(list);
        }
コード例 #4
0
        private void EnsureItemIsVisible(
            object item)
        {
            // Get the native list item container
            NativeListViewItem customItem = this._customSource.GetItem(item);
            var selectorItem = this.ContainerFromItem(customItem) as FrameworkElement;

            if (null == selectorItem)
            {
                // Item is not realized in the list view (it is virtualized)
                return;
            }

            // Find the offset of the item from the top of the view
            var selectorItemTop = selectorItem.TransformToVisual(this).TransformPoint(new global::Windows.Foundation.Point(0, 0));

            // Get the height of the item
            var itemHeight = selectorItem.ActualHeight;

            // Determine whether or not scrolling is necessary
            double scrollBy = 0;

            if (selectorItemTop.Y < 0)
            {
                scrollBy = selectorItemTop.Y;
            }
            else if (selectorItemTop.Y + itemHeight > this.ActualHeight - this.FooterHeight)
            {
                scrollBy = selectorItemTop.Y + itemHeight - this.ActualHeight + this.FooterHeight;
            }

            if (scrollBy != 0)
            {
                var scrollViewer = GetScrollViewer(this);
                scrollViewer.ChangeView(null, scrollViewer.VerticalOffset + scrollBy, zoomFactor: null, disableAnimation: false);
            }
        }