Beispiel #1
0
        private void Mi_Tapped(object sender, TappedRoutedEventArgs e)
        {
            e.Handled = true;
            TabStripItem mi = sender as TabStripItem;

            if (mi != null)
            {
                SelectItem(mi);
                SelectionChanged?.Invoke(this, mi.DataContext.ToString());
            }
        }
Beispiel #2
0
        private void Render()
        {
            pnlItems.Children.Clear();
            if (Items != null)
            {
                foreach (var item in Items)
                {
                    TabStripItem mi = new TabStripItem();
                    mi.DataContext = item;
                    pnlItems.Children.Add(mi);
                    mi.Tapped += Mi_Tapped;
                }

                RenderPositionButtons();
            }
        }
Beispiel #3
0
        private void SelectItem(TabStripItem mi)
        {
            var selectedItems = pnlItems.Children.OfType <TabStripItem>().Where(p => p.IsSelected == true).ToList();

            if (selectedItems.Count() > 0)
            {
                foreach (var item in selectedItems)
                {
                    if (item != mi)
                    {
                        item.IsSelected = false;
                    }
                }
            }

            if (mi != null)
            {
                ScalarKeyFrameAnimation fadeIn = null;
                if (selectedItems.Count == 0)
                {
                    fadeIn = _compositor.CreateScalarKeyFrameAnimation(null, 1, 250, 0);
                }

                mi.IsSelected = true;
                var x = GetIndicatorPositionForItem(mi);

                if (fadeIn != null)
                {
                    _barIndicatorVisual.Offset = new Vector3(x.ToFloat(), 0, 0);
                    _barIndicatorVisual.StartAnimation("Opacity", fadeIn);
                }
                else
                {
                    var animation = _compositor.CreateVector3KeyFrameAnimation(null, new Vector3(x.ToFloat(), 0, 0), 250);
                    _barIndicatorVisual.StartAnimation("Offset", animation);
                }
            }
            else
            {
                var fadeOut = _compositor.CreateScalarKeyFrameAnimation(null, 0, 250, 0);
                _barIndicatorVisual.StartAnimation("Opacity", fadeOut);
            }
        }
Beispiel #4
0
        private Double GetIndicatorPositionForItem(TabStripItem item)
        {
            var position = item.RelativePosition(pnlItems);

            return(position.X - IndicatorWidth / 2 + item.ActualWidth / 2);
        }