File tree Expand file tree Collapse file tree
XamlToolkit.WinUI.Controls/Segmented Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ namespace winrt::XamlToolkit::WinUI::Controls::implementation
1212 SegmentedItem::SegmentedItem ()
1313 {
1414 DefaultStyleKey (winrt::box_value (winrt::xaml_typename<class_type>()));
15+ RegisterPropertyChangedCallback (UIElement::VisibilityProperty (), { this , &SegmentedItem::OnVisibilityChanged });
1516 }
1617
1718 void SegmentedItem::OnApplyTemplate ()
@@ -21,6 +22,19 @@ namespace winrt::XamlToolkit::WinUI::Controls::implementation
2122 ContentChanged ();
2223 }
2324
25+ void SegmentedItem::OnVisibilityChanged (DependencyObject const & sender, DependencyProperty const & dp)
26+ {
27+ // If the parent is a Segmented control with an EqualPanel,
28+ // we need to invalidate measure to update the layout.
29+ if (auto segmented = Parent ().try_as <winrt::XamlToolkit::WinUI::Controls::Segmented>())
30+ {
31+ if (auto panel = segmented.ItemsPanelRoot ().try_as <Panel>())
32+ {
33+ panel.InvalidateMeasure ();
34+ }
35+ }
36+ }
37+
2438 void SegmentedItem::OnContentChanged (IInspectable const & oldContent, IInspectable const & newContent)
2539 {
2640 base_type::OnContentChanged (oldContent, newContent);
Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ namespace winrt::XamlToolkit::WinUI::Controls::implementation
1919
2020 void OnApplyTemplate ();
2121
22+ void OnVisibilityChanged (DependencyObject const & sender, DependencyProperty const & dp);
23+
2224 void OnContentChanged (IInspectable const & oldContent, IInspectable const & newContent);
2325
2426 void ContentChanged ();
You can’t perform that action at this time.
0 commit comments