Skip to content

Commit

Permalink
fix: 修复 SimpleStackPanel 的子项绑定有时不起作用的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Blinue committed Apr 7, 2024
1 parent 002645b commit e40aaa6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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

0 comments on commit e40aaa6

Please sign in to comment.