Skip to content

Commit 2bd06a8

Browse files
Fix SegmentedItem visibility issue (#728)
* Re-measure the Segmented control when any SegmentedItem’s Visibility toggles * Apply suggestion from @Arlodotexe --------- Co-authored-by: Arlo <[email protected]>
1 parent 4738651 commit 2bd06a8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

components/Segmented/src/SegmentedItem/SegmentedItem.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
56
namespace CommunityToolkit.WinUI.Controls;
67

78
/// <summary>
@@ -20,6 +21,17 @@ public partial class SegmentedItem : ListViewItem
2021
public SegmentedItem()
2122
{
2223
this.DefaultStyleKey = typeof(SegmentedItem);
24+
RegisterPropertyChangedCallback(VisibilityProperty, OnVisibilityChanged);
25+
}
26+
27+
private void OnVisibilityChanged(DependencyObject sender, DependencyProperty dp)
28+
{
29+
// If the parent is a Segmented control with an EqualPanel,
30+
// we need to invalidate measure to update the layout.
31+
if ((this.Parent as Segmented)?.ItemsPanelRoot is Panel panel)
32+
{
33+
panel.InvalidateMeasure();
34+
}
2335
}
2436

2537
/// <inheritdoc/>

0 commit comments

Comments
 (0)