Add custom titlebar to default Cs and Cpp WinUI template (#4035)
This change adds custom titlebnar to Cs and Cpp template. As a result, any hello world WinUI app created via the template has custom titlebar already applied to it. This provides a better experience for developers as default option takes care of styling of the window. It works better with overall theming. This is a better experience right out of the box. Similar default is followed by MAUI and Template Studio projects.
This commit is contained in:
Родитель
9664ff3740
Коммит
32ff3b99fa
|
@ -26,6 +26,7 @@ namespace $rootnamespace$
|
|||
public $safeitemname$()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.ExtendsContentIntoTitleBar = true; // provides default WinUI custom title bar experience
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace winrt::$rootnamespace$::implementation
|
|||
{
|
||||
// Xaml objects should not call InitializeComponent during construction.
|
||||
// See https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent
|
||||
ExtendsContentIntoTitleBar(true); // provides default WinUI custom title bar experience
|
||||
}
|
||||
|
||||
int32_t MyProperty();
|
||||
|
|
|
@ -8,7 +8,13 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
|
||||
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Top">
|
||||
<StackPanel Margin="20,5,0,0" Height="32" HorizontalAlignment="Stretch">
|
||||
<TextBlock>$safeitemname$</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,10,0,0" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
</Window>
|
||||
|
|
|
@ -8,7 +8,12 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
|
||||
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Top">
|
||||
<StackPanel Margin="20,5,0,0" Height="32" HorizontalAlignment="Stretch">
|
||||
<TextBlock>$safeitemname$</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,10,0,0" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace $safeprojectname$
|
|||
public MainWindow()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.ExtendsContentIntoTitleBar = true; // provides default WinUI custom title bar experience
|
||||
}
|
||||
|
||||
private void myButton_Click(object sender, RoutedEventArgs e)
|
||||
|
|
|
@ -8,7 +8,12 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
|
||||
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Top">
|
||||
<StackPanel Margin="20,5,0,0" Height="32" HorizontalAlignment="Stretch">
|
||||
<TextBlock>$safeitemname$</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,10,0,0" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace $safeprojectname$
|
|||
public MainWindow()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.ExtendsContentIntoTitleBar = true; // provides default WinUI custom title bar experience
|
||||
}
|
||||
|
||||
private void myButton_Click(object sender, RoutedEventArgs e)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
|
|
@ -23,6 +23,8 @@ namespace $safeprojectname$
|
|||
public UnitTestAppWindow()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
this.ExtendsContentIntoTitleBar = true; // provides default WinUI custom title bar experience
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace winrt::$safeprojectname$::implementation
|
|||
{
|
||||
// Xaml objects should not call InitializeComponent during construction.
|
||||
// See https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent
|
||||
ExtendsContentIntoTitleBar(true); // provides default WinUI custom title bar experience
|
||||
}
|
||||
|
||||
int32_t MyProperty();
|
||||
|
|
|
@ -8,7 +8,12 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
|
||||
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Top">
|
||||
<StackPanel Margin="20,5,0,0" Height="32" HorizontalAlignment="Stretch">
|
||||
<TextBlock>$safeitemname$</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,10,0,0" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace winrt::$safeprojectname$::implementation
|
|||
{
|
||||
// Xaml objects should not call InitializeComponent during construction.
|
||||
// See https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent
|
||||
ExtendsContentIntoTitleBar(true); // provides default WinUI custom title bar experience
|
||||
}
|
||||
|
||||
int32_t MyProperty();
|
||||
|
|
|
@ -8,7 +8,12 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
|
||||
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Top">
|
||||
<StackPanel Margin="20,5,0,0" Height="32" HorizontalAlignment="Stretch">
|
||||
<TextBlock>$safeitemname$</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,10,0,0" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
|
|
|
@ -14,6 +14,6 @@ namespace winrt::$safeprojectname$::implementation
|
|||
{
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
|
||||
ExtendsContentIntoTitleBar(true); // provides default WinUI custom title bar experience
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче