diff --git a/src/Controls/docs/Microsoft.Maui.Controls/NavigationPage.xml b/src/Controls/docs/Microsoft.Maui.Controls/NavigationPage.xml index 7c1019c2b690..bcd23a209612 100644 --- a/src/Controls/docs/Microsoft.Maui.Controls/NavigationPage.xml +++ b/src/Controls/docs/Microsoft.Maui.Controls/NavigationPage.xml @@ -1487,7 +1487,14 @@ Backing store for the attached property that gets and sets title views. - To be added. + On Windows, the TitleView will appear in the content area of the MauiToolbar control. By default, the content area's width is auto-sized to the content, with the remaining area made available for toolbar commands. This is to support the default Windows-specific dynamic overflow ability of the commands. If a user wants the TitleView to occupy all of the space not used by toolbar commands, dynamic overflow needs to be turned off, which can be accomplished by calling the Page's SetToolbarDynamicOverflowEnabled PlatformSpecific to false: + + + this.On<WindowsOS>().SetToolbarDynamicOverflowEnabled(false); + + + + diff --git a/src/Controls/src/Core/NavigationPageToolbar.cs b/src/Controls/src/Core/NavigationPageToolbar.cs index b928dd828306..564682dbb427 100644 --- a/src/Controls/src/Core/NavigationPageToolbar.cs +++ b/src/Controls/src/Core/NavigationPageToolbar.cs @@ -158,6 +158,21 @@ void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEvent Color GetBarTextColor() => _currentNavigationPage?.BarTextColor; Color GetIconColor() => (_currentPage != null) ? NavigationPage.GetIconColor(_currentPage) : null; string GetTitle() => _currentPage?.Title; - VisualElement GetTitleView() => (_currentNavigationPage != null) ? NavigationPage.GetTitleView(_currentNavigationPage) : null; + VisualElement GetTitleView() + { + if (_currentNavigationPage == null) + { + return null; + } + + Page target = _currentNavigationPage; + + if (_currentNavigationPage.CurrentPage is Page currentPage) + { + target = currentPage; + } + + return NavigationPage.GetTitleView(target); + } } } diff --git a/src/Core/src/Platform/Windows/MauiToolbar.xaml b/src/Core/src/Platform/Windows/MauiToolbar.xaml index 8f2b640d7cc7..daf083509ff9 100644 --- a/src/Core/src/Platform/Windows/MauiToolbar.xaml +++ b/src/Core/src/Platform/Windows/MauiToolbar.xaml @@ -31,7 +31,8 @@ - +