HandyOrg / HandyOrg/HandyControl

TabControl 在标签页数量溢出的时候, 点击右侧菜单, 跳转标签的逻辑不太合理

Open
#642 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

:thinking: pending discussion
Dominant language
C#
Stars
7.2k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

image
image

我尝试修改了一下, 这样可以达到效果. 没有添加动画. 仅供参考.
`
menuItem.Click += delegate
{
_buttonOverflow.IsChecked = false;

                    var list = GetActualList();
                    if (list == null) return;

                    var actualItem = ItemContainerGenerator.ItemFromContainer(item);
                    if (actualItem == null) return;

                    // 获取tabitem 对象在scrollviewer中的位置
                    var targetX = item.TransformToVisual(_scrollViewerOverflow)
                            .Transform(new Point(_scrollViewerOverflow.HorizontalOffset, 0)).X;

                    // 判断tabitem是否已经显示  如果超出scrollviewer当前显示范围的左右两端
                    if (targetX < _scrollViewerOverflow.HorizontalOffset
                    || targetX > _scrollViewerOverflow.HorizontalOffset + ActualWidth - TabItemWidth)
                    {
                        // 直接跳转到目标位置
                        _scrollViewerOverflow.ScrollToHorizontalOffset(targetX);
                    }

                    item.IsSelected = true;
                };`

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the TabControl implementation and start with the overflow menuItem.Click handler described in the issue, including GetActualList and _scrollViewerOverflow. Reproduce selecting a tab that is outside the visible overflow range, then verify that selecting a menu item brings it into view without unnecessary movement and leaves it selected.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.