Windows Template Studio(桌面中的Winui 3) - 自定义标题栏

发布于 2025-01-31 18:43:02 字数 1323 浏览 2 评论 0原文

我是新手,我正在尝试自定义该应用程序中的标题栏。我已经使用Windows Template Studio为(桌面中的Winui 3)C创建了一个导航视图项目。该应用不会创建mainwindow.xaml。

我已经浏览了 docs ,我已经编辑了app.xaml.cs将其延长到steptscontentIntotItleBar = true。这可以通过扩展内容区域并删除标题栏来起作用,但是我不知道我需要在哪里使用settitlebar,因为我没有mainwindow.xaml来设置UIELEMENT。

    public partial class App : Application
    {
    public static Window MainWindow { get; set; } = new Window();

    public App()
    {
        InitializeComponent();
        UnhandledException += App_UnhandledException;
        Ioc.Default.ConfigureServices(ConfigureServices());
    }

    private void App_UnhandledException(object sender, UnhandledExceptionEventArgs e)
    {

    }

    protected override async void OnLaunched(LaunchActivatedEventArgs args)
    {
        base.OnLaunched(args);
        var activationService = Ioc.Default.GetService<IActivationService>();
        await activationService.ActivateAsync(args);

        MainWindow.Title = "AppDisplayName".GetLocalized();
        MainWindow.ExtendsContentIntoTitleBar = true;
    }

该应用程序如何或何处设置uIELEMENT和settitlebar?

希望这一切都有意义。

使用: VS2019 Windows App SDK Windows模板工作室 Windows 10

Jake

I am a newbie and i am trying to customize the titlebar in the App. I have used Windows Template Studio to create a NavigationView Project for (winui 3 in Desktop) c#. The App does not create a MainWindow.xaml.

I've gone through the docs, which i have edited the app.xaml.cs to extendscontentintotitlebar = true. This works by extending the content area and removing the titlebar, but i don't know where i need to use settitlebar, since i don't have a mainwindow.xaml to set the UIelement.

    public partial class App : Application
    {
    public static Window MainWindow { get; set; } = new Window();

    public App()
    {
        InitializeComponent();
        UnhandledException += App_UnhandledException;
        Ioc.Default.ConfigureServices(ConfigureServices());
    }

    private void App_UnhandledException(object sender, UnhandledExceptionEventArgs e)
    {

    }

    protected override async void OnLaunched(LaunchActivatedEventArgs args)
    {
        base.OnLaunched(args);
        var activationService = Ioc.Default.GetService<IActivationService>();
        await activationService.ActivateAsync(args);

        MainWindow.Title = "AppDisplayName".GetLocalized();
        MainWindow.ExtendsContentIntoTitleBar = true;
    }

How or Where do i set the UIelement and settitlebar in code-behind for the App?

Hope this all makes sense.

Using:
VS2019
Windows App SDK
Windows Template Studio
Windows 10

Jake

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文