Skip to content
Closed
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
1 change: 1 addition & 0 deletions dev/Generated/MetadataSummary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ public MetadataSummary()
NeedsPropChangedCallbackMetadata["NavigationView.OverflowLabelMode"] = true;
NeedsPropChangedCallbackMetadata["NavigationView.PaneDisplayMode"] = true;
NeedsPropChangedCallbackMetadata["NavigationView.PaneFooter"] = true;
NeedsPropChangedCallbackMetadata["NavigationView.PaneHeader"] = true;
NeedsPropChangedCallbackMetadata["NavigationView.PaneTitle"] = true;
NeedsPropChangedCallbackMetadata["NavigationView.PaneToggleButtonStyle"] = true;
NeedsPropChangedCallbackMetadata["NavigationView.SelectedItem"] = true;
Expand Down
2 changes: 1 addition & 1 deletion dev/Generated/NavigationView.properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ void NavigationViewProperties::EnsureProperties()
winrt::name_of<winrt::NavigationView>(),
false /* isAttached */,
ValueHelper<winrt::UIElement>::BoxedDefaultValue(),
nullptr);
winrt::PropertyChangedCallback(&OnPropertyChanged));
}
if (!s_PaneTitleProperty)
{
Expand Down
23 changes: 23 additions & 0 deletions dev/Generated/NavigationViewTemplateSettings.properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CppWinRTActivatableClassWithDPFactory(NavigationViewTemplateSettings)
GlobalDependencyProperty NavigationViewTemplateSettingsProperties::s_BackButtonVisibilityProperty{ nullptr };
GlobalDependencyProperty NavigationViewTemplateSettingsProperties::s_LeftPaneVisibilityProperty{ nullptr };
GlobalDependencyProperty NavigationViewTemplateSettingsProperties::s_OverflowButtonVisibilityProperty{ nullptr };
GlobalDependencyProperty NavigationViewTemplateSettingsProperties::s_PaneTitleProperty{ nullptr };
GlobalDependencyProperty NavigationViewTemplateSettingsProperties::s_PaneToggleButtonVisibilityProperty{ nullptr };
GlobalDependencyProperty NavigationViewTemplateSettingsProperties::s_SingleSelectionFollowsFocusProperty{ nullptr };
GlobalDependencyProperty NavigationViewTemplateSettingsProperties::s_TopPaddingProperty{ nullptr };
Expand Down Expand Up @@ -56,6 +57,17 @@ void NavigationViewTemplateSettingsProperties::EnsureProperties()
ValueHelper<winrt::Visibility>::BoxValueIfNecessary(winrt::Visibility::Collapsed),
nullptr);
}
if (!s_PaneTitleProperty)
{
s_PaneTitleProperty =
InitializeDependencyProperty(
L"PaneTitle",
winrt::name_of<winrt::hstring>(),
winrt::name_of<winrt::NavigationViewTemplateSettings>(),
false /* isAttached */,
ValueHelper<winrt::hstring>::BoxedDefaultValue(),
nullptr);
}
if (!s_PaneToggleButtonVisibilityProperty)
{
s_PaneToggleButtonVisibilityProperty =
Expand Down Expand Up @@ -107,6 +119,7 @@ void NavigationViewTemplateSettingsProperties::ClearProperties()
s_BackButtonVisibilityProperty = nullptr;
s_LeftPaneVisibilityProperty = nullptr;
s_OverflowButtonVisibilityProperty = nullptr;
s_PaneTitleProperty = nullptr;
s_PaneToggleButtonVisibilityProperty = nullptr;
s_SingleSelectionFollowsFocusProperty = nullptr;
s_TopPaddingProperty = nullptr;
Expand Down Expand Up @@ -143,6 +156,16 @@ winrt::Visibility NavigationViewTemplateSettingsProperties::OverflowButtonVisibi
return ValueHelper<winrt::Visibility>::CastOrUnbox(static_cast<NavigationViewTemplateSettings*>(this)->GetValue(s_OverflowButtonVisibilityProperty));
}

void NavigationViewTemplateSettingsProperties::PaneTitle(winrt::hstring const& value)
{
static_cast<NavigationViewTemplateSettings*>(this)->SetValue(s_PaneTitleProperty, ValueHelper<winrt::hstring>::BoxValueIfNecessary(value));
}

winrt::hstring NavigationViewTemplateSettingsProperties::PaneTitle()
{
return ValueHelper<winrt::hstring>::CastOrUnbox(static_cast<NavigationViewTemplateSettings*>(this)->GetValue(s_PaneTitleProperty));
}

void NavigationViewTemplateSettingsProperties::PaneToggleButtonVisibility(winrt::Visibility const& value)
{
static_cast<NavigationViewTemplateSettings*>(this)->SetValue(s_PaneToggleButtonVisibilityProperty, ValueHelper<winrt::Visibility>::BoxValueIfNecessary(value));
Expand Down
5 changes: 5 additions & 0 deletions dev/Generated/NavigationViewTemplateSettings.properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class NavigationViewTemplateSettingsProperties
void OverflowButtonVisibility(winrt::Visibility const& value);
winrt::Visibility OverflowButtonVisibility();

void PaneTitle(winrt::hstring const& value);
winrt::hstring PaneTitle();

void PaneToggleButtonVisibility(winrt::Visibility const& value);
winrt::Visibility PaneToggleButtonVisibility();

Expand All @@ -33,6 +36,7 @@ class NavigationViewTemplateSettingsProperties
static winrt::DependencyProperty BackButtonVisibilityProperty() { return s_BackButtonVisibilityProperty; }
static winrt::DependencyProperty LeftPaneVisibilityProperty() { return s_LeftPaneVisibilityProperty; }
static winrt::DependencyProperty OverflowButtonVisibilityProperty() { return s_OverflowButtonVisibilityProperty; }
static winrt::DependencyProperty PaneTitleProperty() { return s_PaneTitleProperty; }
static winrt::DependencyProperty PaneToggleButtonVisibilityProperty() { return s_PaneToggleButtonVisibilityProperty; }
static winrt::DependencyProperty SingleSelectionFollowsFocusProperty() { return s_SingleSelectionFollowsFocusProperty; }
static winrt::DependencyProperty TopPaddingProperty() { return s_TopPaddingProperty; }
Expand All @@ -41,6 +45,7 @@ class NavigationViewTemplateSettingsProperties
static GlobalDependencyProperty s_BackButtonVisibilityProperty;
static GlobalDependencyProperty s_LeftPaneVisibilityProperty;
static GlobalDependencyProperty s_OverflowButtonVisibilityProperty;
static GlobalDependencyProperty s_PaneTitleProperty;
static GlobalDependencyProperty s_PaneToggleButtonVisibilityProperty;
static GlobalDependencyProperty s_SingleSelectionFollowsFocusProperty;
static GlobalDependencyProperty s_TopPaddingProperty;
Expand Down
12 changes: 12 additions & 0 deletions dev/NavigationView/NavigationView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2598,6 +2598,11 @@ void NavigationView::OnPropertyChanged(const winrt::DependencyPropertyChangedEve
else if (property == s_PaneTitleProperty)
{
UpdatePaneToggleSize();
UpdatePaneTitleInTemplateSettings();
}
else if (property == s_PaneHeaderProperty)
{
UpdatePaneTitleInTemplateSettings();
}
else if (property == s_IsBackButtonVisibleProperty)
{
Expand Down Expand Up @@ -3320,6 +3325,13 @@ void NavigationView::UpdateTitleBarPadding()
}
}

void NavigationView::UpdatePaneTitleInTemplateSettings()
{
// PaneTitle is introduced in RS4, but it's a string, PaneHeader would deprecate PaneTitle
// Make TemplateSettings.PaneTitle to empty when PaneHeader exists.
GetTemplateSettings()->PaneTitle(PaneHeader() ? L"" : PaneTitle());
}

void NavigationView::UpdateSelectedItem()
{
auto item = SelectedItem();
Expand Down
1 change: 1 addition & 0 deletions dev/NavigationView/NavigationView.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class NavigationView :
void OnTitleBarMetricsChanged(const winrt::IInspectable& sender, const winrt::IInspectable& args);
void OnTitleBarIsVisibleChanged(const winrt::CoreApplicationViewTitleBar& sender, const winrt::IInspectable& args);
void UpdateTitleBarPadding();
void UpdatePaneTitleInTemplateSettings();

void RaiseDisplayModeChanged(const winrt::NavigationViewDisplayMode& displayMode);
void AnimateSelectionChanged(const winrt::IInspectable& lastItem, const winrt::IInspectable& currentItem);
Expand Down
12 changes: 9 additions & 3 deletions dev/NavigationView/NavigationView.idl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[WUXC_VERSION_RS3]
[WUXC_VERSION_RS3]
[webhosthidden]
enum NavigationViewDisplayMode
{
Expand Down Expand Up @@ -135,6 +135,12 @@ unsealed runtimeclass NavigationViewTemplateSettings : Windows.UI.Xaml.Dependenc
static Windows.UI.Xaml.DependencyProperty TopPaneVisibilityProperty { get; };
static Windows.UI.Xaml.DependencyProperty LeftPaneVisibilityProperty { get; };
static Windows.UI.Xaml.DependencyProperty SingleSelectionFollowsFocusProperty { get; };

[WUXC_VERSION_MUXONLY]
{
String PaneTitle{ get; };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New APIs require API doc (since this will appear on MSDN). Please do that process before completing this PR. You can model your doc after this one: microsoft/microsoft-ui-xaml-specs#13.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static Windows.UI.Xaml.DependencyProperty PaneTitleProperty{ get; };
}
}

[WUXC_VERSION_RS3]
Expand Down Expand Up @@ -234,7 +240,7 @@ unsealed runtimeclass NavigationView : Windows.UI.Xaml.Controls.ContentControl
{
[MUX_DEFAULT_VALUE("winrt::NavigationViewPaneDisplayMode::Auto")]
NavigationViewPaneDisplayMode PaneDisplayMode { get; set; };
[MUX_PROPERTY_CHANGED_CALLBACK(FALSE)]
[MUX_PROPERTY_CHANGED_CALLBACK(TRUE)]
Windows.UI.Xaml.UIElement PaneHeader { get; set; };
[MUX_PROPERTY_CHANGED_CALLBACK(FALSE)]
Windows.UI.Xaml.UIElement PaneCustomContent { get; set; };
Expand Down Expand Up @@ -323,4 +329,4 @@ unsealed runtimeclass NavigationViewItemSeparator : NavigationViewItemBase
unsealed runtimeclass NavigationViewItemHeader : NavigationViewItemBase
{
NavigationViewItemHeader();
}
}
2 changes: 1 addition & 1 deletion dev/NavigationView/NavigationView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
<TextBlock
x:Name="PaneTitleTextBlock"
Grid.Column="0"
Text="{TemplateBinding PaneTitle}"
Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.PaneTitle}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Style="{StaticResource NavigationViewItemHeaderTextStyle}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2844,6 +2844,23 @@ public void VerifyPaneTitlePresentAndUpdates()
}
}

[TestMethod]
[TestProperty("NavViewTestSuite", "C")]
public void VerifyPaneTitleIsEmptyWhenPaneHeaderIsSet()
{
using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "NavigationView Test" }))
{
TextBlock paneTitleTextBlock = new TextBlock(FindElement.ByName("NavView Test"));

Verify.AreNotEqual("", paneTitleTextBlock.DocumentText, "Verify that the pane title is not empty");

Button changePaneTitleButton = new Button(FindElement.ByName("ChangePaneHeader"));
changePaneTitleButton.Invoke();
Wait.ForIdle();

Verify.AreEqual("", paneTitleTextBlock.DocumentText, "Verify that the pane title is empty");
}
}

[TestMethod]
[TestProperty("NavViewTestSuite", "C")]
Expand Down