private void AnchorPointPanel_MouseEnter(object sender, MouseEventArgs e)
        {
            DoubleAnimation daV       = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(1)));
            var             scrollBar = MyVisualTreeHelper.FindChild <ScrollBar>(this.scrollViewer, "PART_VerticalScrollBar");

            scrollBar.BeginAnimation(UIElement.OpacityProperty, daV);
        }
        /// <summary>
        /// 隐藏最右边的线
        /// </summary>
        private void RemoveRightLine()
        {
            ListBoxItem item = (ListBoxItem)this.ItemContainerGenerator.ContainerFromIndex(this.Items.Count - 1);

            if (item != null)
            {
                var border = MyVisualTreeHelper.FindChild <Border>(item, "PART_RightLine");
                if (border != null)
                {
                    border.Visibility = Visibility.Collapsed;
                }
            }
        }
        private void SegmentButton_Loaded(object sender, RoutedEventArgs e)
        {
            var borderList = MyVisualTreeHelper.FindVisualChildren <Border>(this, "PART_ButtonSpliteLine").ToList();

            if (borderList != null)
            {
                for (int i = 0; i < borderList.Count; i++)
                {
                    //隐藏最后一个分隔线
                    if (i == this.Items.Count - 1)
                    {
                        var border = borderList[i];
                        border.Visibility = Visibility.Collapsed;
                    }
                }
            }

            int itemsCount = this.Items.Count;

            if (itemsCount > 0)
            {
                var listboxitem = this.ItemContainerGenerator.ContainerFromIndex(0) as FrameworkElement;
                var border      = MyVisualTreeHelper.FindChild <Border>(listboxitem, "PART_ItemBorder");
                if (border != null)
                {
                    //如果控件只有一项的时候,需要重新设置边框的圆角
                    if (itemsCount == 1)
                    {
                        border.CornerRadius = new CornerRadius(5, 5, 5, 5);
                    }
                    else
                    {
                        if (this.SelectedIndex == 0)
                        {
                            border.CornerRadius = new CornerRadius(5, 0, 0, 5);
                        }
                        else if (this.SelectedIndex == itemsCount - 1)
                        {
                            border.CornerRadius = new CornerRadius(5, 5, 5, 5);
                        }
                        else
                        {
                            border.CornerRadius = new CornerRadius(0, 0, 0, 0);
                        }
                    }
                }
            }
        }
        private void SegmentButton_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int index       = this.SelectedIndex;
            var listboxitem = this.ItemContainerGenerator.ContainerFromIndex(index) as FrameworkElement;
            var border      = MyVisualTreeHelper.FindChild <Border>(listboxitem, "PART_ItemBorder");

            if (border != null)
            {
                if (index == 0)
                {
                    border.CornerRadius = new CornerRadius(5, 0, 0, 5);
                }
                else if (index == this.Items.Count - 1)
                {
                    border.CornerRadius = new CornerRadius(0, 5, 5, 0);
                }
                else
                {
                    border.CornerRadius = new CornerRadius(0, 0, 0, 0);
                }
            }
        }