Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Settings] Fix flyout position when ComboBox is aligned to the right #31

Merged
merged 7 commits into from
Feb 19, 2023
Merged

[Settings] Fix flyout position when ComboBox is aligned to the right #31

merged 7 commits into from
Feb 19, 2023

Conversation

gaviny82
Copy link
Collaborator

Fix #30 #28 (partial)

@xingxing2008 xingxing2008 marked this pull request as ready for review February 18, 2023 01:31
@gaviny82
Copy link
Collaborator Author

建议暂时不要合并,正在尝试更好的解决方案

@xingxing2008
Copy link
Member

还没打算合并,等待你修改完成,今天晚上natsurainko估计会修改一部分代码,注意merge分支哈

@gaviny82
Copy link
Collaborator Author

初步实现了根据路径长度计算ComboBox宽度,正在进行更多测试
image

Comment on lines 90 to 92
//TODO: combobox.items are not necessarily ComboBoxItems
// var cont = comboBox.ContainerFromIndex(0);
// var a = comboBox.ItemContainerGenerator.ContainerFromItem(item);
Copy link
Collaborator Author

@gaviny82 gaviny82 Feb 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本来应该用ItemContainerGenerator获取容器宽度的,但是这一组API好像已经弃用了(ItemContainerGenerator Class | MS Learn),使用GenerateNext也总是返回null,不确定是不是控件加载顺序的问题。

现在的方法是new TextBlock然后获取DesiredSize加上一个固定的宽度,对于string类型的ComboBoxItem没问题,如果设置了ItemTemplate就不能用。

@gaviny82
Copy link
Collaborator Author

在测试项目中实现了通过ItemContainerGenerator计算最大宽度
Animation

使用DataTemplate:
Animation

向右对齐:
Animation

@gaviny82
Copy link
Collaborator Author

基本上改完了,还剩最后一个问题:路径过长时应该限制最大宽度。绑定一下MaxWidth就好了
image

@gaviny82 gaviny82 changed the title [WIP][Settings] Fix flyout position when ComboBox is aligned to the right [Settings] Fix flyout position when ComboBox is aligned to the right Feb 19, 2023
@natsurainko natsurainko merged commit 118d8e0 into Xcube-Studio:winui3-edition Feb 19, 2023
natsurainko added a commit that referenced this pull request Feb 19, 2023
@xingxing2008 xingxing2008 added bug Something isn't working help wanted Extra attention is needed labels Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

奇怪的 UI 界面
3 participants