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

修复 SimpleStackPanel 的子项绑定有时不起作用的问题 #885

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Magpie.App/ScalingConfigurationPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@
</ListView.ItemContainerTransitions>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<!-- SimpleStackPanel 不支持拖拽 -->
<!-- SimpleStackPanel 不支持拖放 -->
<StackPanel ChildrenTransitions="{StaticResource SettingsCardsAnimations}"
Orientation="Vertical" />
</ItemsPanelTemplate>
Expand Down
4 changes: 3 additions & 1 deletion src/Magpie.App/SimpleStackPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ Size SimpleStackPanel::MeasureOverride(const Size& availableSize) const {
Size finalSize{ paddings.Width, paddings.Height };

for (UIElement const& item : Children()) {
// 调用 Measure 可以初始化绑定,因此即使子项不可见也要调用
item.Measure(childAvailableSize);

if (item.Visibility() == Visibility::Collapsed) {
// 不可见的子项不添加间距
continue;
}

item.Measure(childAvailableSize);
const Size itemSize = item.DesiredSize();

if (isVertical) {
Expand Down