Beispiel #1
0
        /// <summary>
        /// 设置SegmentItem的位置属性
        /// </summary>
        /// <param name="index"></param>
        private void SetButtonGroupItem(int index)
        {
            if (index > this.Items.Count || index < 0)
            {
                return;
            }

            ButtonGroupItem buttonGroupItem = this.ItemContainerGenerator.ContainerFromIndex(index) as ButtonGroupItem;

            if (buttonGroupItem == null)
            {
                return;
            }
            buttonGroupItem.IsFirstItem  = index == 0;
            buttonGroupItem.IsLastItem   = index == this.Items.Count - 1;
            buttonGroupItem.IsMiddleItem = index > 0 && index < this.Items.Count - 1;
        }
Beispiel #2
0
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            int             index           = this.ItemContainerGenerator.IndexFromContainer(element);
            ButtonGroupItem buttonGroupItem = element as ButtonGroupItem;

            if (buttonGroupItem == null)
            {
                return;
            }

            if (index == 0)
            {
                buttonGroupItem.IsFirstItem  = true;
                buttonGroupItem.CornerRadius = new CornerRadius(this.CornerRadius.TopLeft, 0, 0, this.CornerRadius.BottomLeft);
            }

            if (index == this.Items.Count - 1)
            {
                buttonGroupItem.IsLastItem   = true;
                buttonGroupItem.CornerRadius = new CornerRadius(0, this.CornerRadius.TopRight, this.CornerRadius.BottomRight, 0);
            }

            base.PrepareContainerForItemOverride(buttonGroupItem, item);
        }