(selectedHeight);
- }
- }
-
- private void AddInteractiveElements_Click(object sender, RoutedEventArgs e)
- {
- var txtBoxNonClientArea = UIHelper.FindElementByName(sender as UIElement, "AppTitleBarTextBox") as FrameworkElement;
-
- if (txtBoxNonClientArea.Visibility == Visibility.Visible)
- {
- ResetTitlebarSettings();
- }
- else
- {
- addInteractiveElements.Content = "Remove interactive control from titlebar";
- txtBoxNonClientArea.Visibility = Visibility.Visible;
- if (sizeChangedEventHandlerAdded)
- {
- setTxtBoxAsPasthrough(txtBoxNonClientArea);
- }
- else
- {
- sizeChangedEventHandlerAdded = true;
- // run this code when textbox has been made visible and its actual width and height has been calculated
- txtBoxNonClientArea.SizeChanged += (object sender, SizeChangedEventArgs e) =>
- {
- if (txtBoxNonClientArea.Visibility != Visibility.Collapsed)
- {
- setTxtBoxAsPasthrough(txtBoxNonClientArea);
- }
- };
- }
-
- // announce visual change to automation
- UIHelper.AnnounceActionForAccessibility(sender as UIElement, "TitleBar size and width changed", "TitleBarChangedNotificationActivityId");
- }
- }
-
}
diff --git a/WinUIGallery/Samples/Data/ControlInfoData.json b/WinUIGallery/Samples/Data/ControlInfoData.json
index 3bcc0209d..8090c96d7 100644
--- a/WinUIGallery/Samples/Data/ControlInfoData.json
+++ b/WinUIGallery/Samples/Data/ControlInfoData.json
@@ -3622,20 +3622,20 @@
{
"UniqueId": "TitleBar",
"Title": "TitleBar",
- "ApiNamespace": "Microsoft.UI.Xaml",
+ "ApiNamespace": "Microsoft.UI.Xaml.Controls",
"Subtitle": "An example showing a custom UIElement used as the titlebar for the app's window.",
"ImagePath": "ms-appx:///Assets/ControlImages/TitleBar.png",
- "Description": "This sample shows how to use a custom titlebar for the app's window. There are 2 ways of doing it: using default titlebar and setting an UIElement as a custom titlebar.",
+ "Description": "The TitleBar control provides a simple way to create a modern titlebar UX with interactive content.",
"Content": "Look at the TitleBarPage.xaml file in Visual Studio to see the full code for this page.
",
"IsUpdated": true,
"Docs": [
{
- "Title": "TitleBar - API",
- "Uri": "https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.window.extendscontentintotitlebar"
+ "Title": "Title bar customization",
+ "Uri": "https://learn.microsoft.com/windows/apps/develop/title-bar"
},
{
- "Title": "Guidelines",
- "Uri": "https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.window"
+ "Title": "Titl bar - design guidelines",
+ "Uri": "https://learn.microsoft.com/windows/apps/design/basics/titlebar-design"
}
],
"RelatedControls": [
diff --git a/WinUIGallery/Samples/SamplePages/ModalWindow.xaml.cs b/WinUIGallery/Samples/SamplePages/ModalWindow.xaml.cs
index cc594c813..469b2ce20 100644
--- a/WinUIGallery/Samples/SamplePages/ModalWindow.xaml.cs
+++ b/WinUIGallery/Samples/SamplePages/ModalWindow.xaml.cs
@@ -21,7 +21,7 @@ public ModalWindow()
// Set this modal window's owner (the main application window).
// The main window can be retrieved from App.xaml.cs if it's set as a static property.
- SetOwnership(appWindow, App.StartupWindow);
+ SetOwnership(appWindow, App.MainWindow);
// Make the window modal (blocks interaction with the owner window until closed).
presenter.IsModal = true;
@@ -74,7 +74,7 @@ private void SetOwnership(AppWindow ownedAppWindow, Window ownerWindow)
private void ModalWindow_Closed(object sender, WindowEventArgs args)
{
// Reactivate the main application window when the modal window closes.
- App.StartupWindow.Activate();
+ App.MainWindow.Activate();
}
private void OKButton_Click(object sender, RoutedEventArgs e)
diff --git a/WinUIGallery/Samples/SamplePages/TitleBarWindow.xaml b/WinUIGallery/Samples/SamplePages/TitleBarWindow.xaml
new file mode 100644
index 000000000..9422d4335
--- /dev/null
+++ b/WinUIGallery/Samples/SamplePages/TitleBarWindow.xaml
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WinUIGallery/Samples/SamplePages/TitleBarWindow.xaml.cs b/WinUIGallery/Samples/SamplePages/TitleBarWindow.xaml.cs
new file mode 100644
index 000000000..b89bebd06
--- /dev/null
+++ b/WinUIGallery/Samples/SamplePages/TitleBarWindow.xaml.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Linq;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+
+namespace WinUIGallery.Samples.SamplePages;
+
+public sealed partial class TitleBarWindow : Window
+{
+ public TitleBarWindow()
+ {
+ this.InitializeComponent();
+ this.ExtendsContentIntoTitleBar = true; // Extend the content into the title bar and hide the default title bar
+ this.AppWindow.TitleBar.PreferredHeightOption = Microsoft.UI.Windowing.TitleBarHeightOption.Tall;
+ this.SetTitleBar(titleBar); // Set the custom title bar
+ navView.SelectedItem = navView.MenuItems.OfType().First();
+ }
+
+ private void TitleBar_PaneToggleRequested(TitleBar sender, object args)
+ {
+ navView.IsPaneOpen = !navView.IsPaneOpen;
+ }
+
+ private void TitleBar_BackRequested(TitleBar sender, object args)
+ {
+ navFrame.GoBack();
+ }
+
+ private void navView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
+ {
+ var selectedItem = (NavigationViewItem)args.SelectedItem;
+ if (selectedItem != null)
+ {
+ string selectedItemTag = ((string)selectedItem.Tag);
+ sender.Header = "Sample Page " + selectedItemTag.Substring(selectedItemTag.Length - 1);
+ string pageName = "WinUIGallery.SamplePages." + selectedItemTag;
+ Type pageType = Type.GetType(pageName);
+ navFrame.Navigate(pageType);
+ }
+ }
+}
diff --git a/WinUIGallery/Styles/TitleBar.xaml b/WinUIGallery/Styles/TitleBar.xaml
new file mode 100644
index 000000000..5a0754d2a
--- /dev/null
+++ b/WinUIGallery/Styles/TitleBar.xaml
@@ -0,0 +1,285 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WinUIGallery/WinUIGallery.csproj b/WinUIGallery/WinUIGallery.csproj
index b0eec4242..27150a930 100644
--- a/WinUIGallery/WinUIGallery.csproj
+++ b/WinUIGallery/WinUIGallery.csproj
@@ -297,6 +297,7 @@
+
@@ -306,11 +307,13 @@
+
+
@@ -487,6 +490,18 @@
+
+
+ MSBuild:Compile
+
+
+
+
+
+ MSBuild:Compile
+
+
+
MSBuild:Compile
@@ -537,6 +552,12 @@
MSBuild:Compile
+
+
+
+ MSBuild:Compile
+
+
MSBuild:Compile
diff --git a/standalone.props b/standalone.props
index 8738d66f4..cfb0df268 100644
--- a/standalone.props
+++ b/standalone.props
@@ -1,24 +1,24 @@
-
-
- 10.0.22621.42
- 1.6.250108002
- 6.2.11
- 1.0.4
- 2.0.13
- 8.0.230907
- 2.0.3
-
- obj\$(MSBuildProjectName)\
- bin\$(MSBuildProjectName)\
-
+ 10.0.22621.42
+ 1.7.250208002-preview1
+ 6.2.11
+ 1.3.2
+ 2.0.15
+ 8.1.240916
+ 2.2.0
+
+ obj\$(MSBuildProjectName)\
+ bin\$(MSBuildProjectName)\
+
- obj\**;bin\**;$(DefaultItemExcludes)
-
- obj\generated
-
+ obj\**;bin\**;$(DefaultItemExcludes)
+
+ obj\generated
+
\ No newline at end of file