Just a quick clarification needed regarding.setTitleBar() usage.
MainWindow.xaml
<Window
x:Class="Wrath.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Wrath"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid>
<!-- ... -->
<TextBlock x:Name="CustomTitleBar">Custom title text</TextBlock>
<!-- ... -->
</Grid>
</Window>
MainWindow.xaml.cpp
MainWindow::ExtendsContentIntoTitleBar(true);
MainWindow::SetTitleBar(?);
How do I reference the xaml element as argument in the SetTitleBar function?
This is based on the example (only for.cs) provided from:
As of project reunion 0.8, I have been able to successfully set the titlebar as follows:
In your MainWindow.xaml.cpp file:
MainWindow::MainWindow()
{
InitializeComponent();
this->ExtendsContentIntoTitleBar(true);
this->SetTitleBar(AppTitleBar());
}
In your MainWindow.xaml file somewhere:
<Grid x:Name="AppTitleBar">
... titlebar code goes here
</Grid>
As of the 1.0 release this is the preferred way. https://docs.microsoft.com/en-us/windows/winui/api/microsoft.ui.xaml.window.settitlebar?view=winui-3.0
<Window...> <Grid> <.--..: --> <TextBlock x.Name="CustomTitleBar">Custom title text</TextBlock> <.--... --> </Grid> </Window>
with
private MainWindow m_window; protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args) { m_window = new MainWindow(); m_window.ExtendsContentIntoTitleBar = true; m_window.SetTitleBar(m_window.CustomTitleBar); m_window.Activate(); }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.