Example #1
0
        private CarruselItemTemplate CreatePlaceHolder()
        {
            CarruselItemTemplate item = new CarruselItemTemplate();

            item.Background = new SolidColorBrush(Colors.Yellow);
            item.Width      = _itemWidth;
            item.Height     = _itemHeight;

            item.GetVisual().CenterPoint = new Vector3((float)_itemWidth * .5f, (float)_itemHeight * .5f, 0f);
            item.BackgroundPanel.CenterPoint = new Vector3((float)_itemWidth * .5f, (float)_itemHeight * .5f, 0f);

            return(item);
        }
Example #2
0
        private void InitializeLayout()
        {
            if (items.Count < 3)
            {
                throw new ArgumentException("Not enought items");
            }

            center = CreatePlaceHolder();
            center.Shadow.Opacity = 0;
            center.DataContext    = items[_indexSelectedInItemsCollection];
            pnlRoot.Children.Add(center);
            itemsRendered.AddRight(center);

            var rightIdx = _indexSelectedInItemsCollection;
            var leftIdx  = _indexSelectedInItemsCollection;

            //render two items on the right and two items on the left
            for (int i = 1; i <= 2; i++)
            {
                rightIdx             = GetRight(rightIdx);
                right                = CreatePlaceHolder();
                right.DataContext    = items[rightIdx];
                right.Shadow.Opacity = 0;
                pnlRoot.Children.Add(right);
                right.GetVisual().Offset = new System.Numerics.Vector3((float)right.Width * i, 0, 0);
                itemsRendered.AddRight(right);


                leftIdx             = GetLeft(leftIdx);
                left                = CreatePlaceHolder();
                left.DataContext    = items[leftIdx];
                left.Shadow.Opacity = 0;
                pnlRoot.Children.Add(left);
                left.GetVisual().Offset = new System.Numerics.Vector3(-(float)right.Width * i, 0, 0);
                itemsRendered.AddLeft(left);
            }

            ConfigureMinMax();
        }