in dev/NavigationView/NavigationView.cpp [3916:4079]
void NavigationView::OnPropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args)
{
winrt::IDependencyProperty property = args.Property();
if (property == s_IsPaneOpenProperty)
{
OnIsPaneOpenChanged();
UpdateVisualStateForDisplayModeGroup(DisplayMode());
}
else if (property == s_CompactModeThresholdWidthProperty ||
property == s_ExpandedModeThresholdWidthProperty)
{
UpdateAdaptiveLayout(ActualWidth());
}
else if (property == s_AlwaysShowHeaderProperty || property == s_HeaderProperty)
{
UpdateHeaderVisibility();
}
else if (property == s_SelectedItemProperty)
{
OnSelectedItemPropertyChanged(args);
}
else if (property == s_PaneTitleProperty)
{
UpdatePaneTitleFrameworkElementParents();
UpdateBackAndCloseButtonsVisibility();
UpdatePaneToggleSize();
}
else if (property == s_IsBackButtonVisibleProperty)
{
UpdateBackAndCloseButtonsVisibility();
UpdateAdaptiveLayout(ActualWidth());
if (IsTopNavigationView())
{
InvalidateTopNavPrimaryLayout();
}
if (g_IsTelemetryProviderEnabled && IsBackButtonVisible() == winrt::NavigationViewBackButtonVisible::Collapsed)
{
// Explicitly disabling BackUI on NavigationView
[[gsl::suppress(con.4)]] TraceLoggingWrite(
g_hTelemetryProvider,
"NavigationView_DisableBackUI",
TraceLoggingDescription("Developer explicitly disables the BackUI on NavigationView"));
}
// Enabling back button shifts grid instead of resizing, so let's update the layout.
if (const auto& backButton = m_backButton.get())
{
backButton.UpdateLayout();
}
UpdatePaneLayout();
}
else if (property == s_MenuItemsSourceProperty)
{
UpdateRepeaterItemsSource(true /*forceSelectionModelUpdate*/);
}
else if (property == s_MenuItemsProperty)
{
UpdateRepeaterItemsSource(true /*forceSelectionModelUpdate*/);
}
else if (property == s_FooterMenuItemsSourceProperty)
{
UpdateFooterRepeaterItemsSource(true /*sourceCollectionReset*/, true /*sourceCollectionChanged*/);
}
else if (property == s_FooterMenuItemsProperty)
{
UpdateFooterRepeaterItemsSource(true /*sourceCollectionReset*/, true /*sourceCollectionChanged*/);
}
else if (property == s_PaneDisplayModeProperty)
{
// m_wasForceClosed is set to true because ToggleButton is clicked and Pane is closed.
// When PaneDisplayMode is changed, reset the force flag to make the Pane can be opened automatically again.
m_wasForceClosed = false;
CollapseTopLevelMenuItems(auto_unbox(args.OldValue()));
UpdatePaneToggleButtonVisibility();
UpdatePaneDisplayMode(auto_unbox(args.OldValue()), auto_unbox(args.NewValue()));
UpdatePaneTitleFrameworkElementParents();
UpdatePaneVisibility();
UpdateVisualState();
UpdatePaneButtonsWidths();
}
else if (property == s_IsPaneVisibleProperty)
{
UpdatePaneVisibility();
UpdateVisualStateForDisplayModeGroup(DisplayMode());
// When NavView is in expaneded mode with fixed window size, setting IsPaneVisible to false doesn't closes the pane
// We manually close/open it for this case
if (!IsPaneVisible() && IsPaneOpen())
{
ClosePane();
}
if (IsPaneVisible() && DisplayMode() == winrt::NavigationViewDisplayMode::Expanded && !IsPaneOpen())
{
OpenPane();
}
}
else if (property == s_OverflowLabelModeProperty)
{
if (m_appliedTemplate)
{
UpdateVisualStateForOverflowButton();
InvalidateTopNavPrimaryLayout();
}
}
else if (property == s_AutoSuggestBoxProperty)
{
InvalidateTopNavPrimaryLayout();
if (args.OldValue())
{
m_autoSuggestBoxQuerySubmittedRevoker.revoke();
}
if (const auto newAutoSuggestBox = args.NewValue().try_as<winrt::AutoSuggestBox>())
{
m_autoSuggestBoxQuerySubmittedRevoker = newAutoSuggestBox.QuerySubmitted(winrt::auto_revoke, {this, &NavigationView::OnAutoSuggestBoxQuerySubmitted });
}
UpdateVisualState(false);
}
else if (property == s_SelectionFollowsFocusProperty)
{
UpdateSingleSelectionFollowsFocusTemplateSetting();
}
else if (property == s_IsPaneToggleButtonVisibleProperty)
{
UpdatePaneTitleFrameworkElementParents();
UpdateBackAndCloseButtonsVisibility();
UpdatePaneToggleButtonVisibility();
UpdateVisualState();
}
else if (property == s_IsSettingsVisibleProperty)
{
UpdateFooterRepeaterItemsSource(false /*sourceCollectionReset*/, true /*sourceCollectionChanged*/);
}
else if (property == s_CompactPaneLengthProperty)
{
if (!SharedHelpers::Is21H1OrHigher())
{
// Need to update receiver margins when CompactPaneLength changes
UpdatePaneShadow();
}
// Update pane-button-grid width when pane is closed and we are not in minimal
UpdatePaneButtonsWidths();
}
else if (property == s_IsTitleBarAutoPaddingEnabledProperty)
{
UpdateTitleBarPadding();
}
else if (property == s_MenuItemTemplateProperty ||
property == s_MenuItemTemplateSelectorProperty)
{
SyncItemTemplates();
}
else if (property == s_PaneFooterProperty)
{
UpdatePaneLayout();
}
else if (property == s_OpenPaneLengthProperty)
{
UpdateOpenPaneWidth(ActualWidth());
}
}