microsoft-ui-xaml: Unable to set Window Title in XAML
Describe the bug
In WinUI3preview3, unable to build a project if set the Window Title in XAML.
Steps to reproduce the bug
- Create a new
Blank App, Packaged (WinUI in Desktop) - Change the content of
MainWindow.xamlto add the following on line 8
<Window
x:Class="App68.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App68"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="my app"
mc:Ignorable="d">
- Build the solution
- See an exception:
MainWindow.xaml(8,5): XamlCompiler error WMC0612: The XAML Binary Format (XBF) generator reported syntax error '0x09C4' : Property Not Found
- Remove the change in the XAML file and set the window Title in the constructor. e.g.:
public MainWindow()
{
this.InitializeComponent();
this.Title = "my app";
}
- Run the app and see the title displayed correctly.
Expected behavior
It should be possible to set the Window Title in XAML.
Screenshots
Version Info
NuGet package version: Microsoft.WinUI 3.0.0-preview3.201113.0
Windows app type:
| UWP | Win32 |
|---|---|
| Yes |
| Windows 10 version | Saw the problem? |
|---|---|
| Insider Build (xxxxx) | |
| May 2020 Update (19041) | Yes |
| November 2019 Update (18363) | |
| May 2019 Update (18362) | |
| October 2018 Update (17763) | |
| April 2018 Update (17134) | |
| Fall Creators Update (16299) | |
| Creators Update (15063) |
| Device form factor | Saw the problem? |
|---|---|
| Desktop | Yes |
| Xbox | |
| Surface Hub | |
| IoT |
Additional context
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 25
- Comments: 47 (21 by maintainers)
Commits related to this issue
- https://github.com/microsoft/microsoft-ui-xaml/issues/3689 this issue finally got solved! Yay! — committed to kaismic/Hitomi-Scroll-Viewer by kaismic 3 years ago
Unfortunately, per the latest engineering plan, the bug fix won’t make the v1.0 Stable release (GA) and was moved to v1.1
This is ridiculous as a so basic function doesn’t work on the official version 1.0.
⚠ Still a bug in Preview 4. @StephenLPeters
Still not fix in Reunion 0.8
Wow it works. The end of an era!
There is an (ugly) workaround though. In your Window sub class add this:
I had to apply that workaround to WinUIEx well: https://github.com/dotMorten/WinUIEx/blob/86c86233512565873ffc413342dd88ed04dbca14/src/WinUIEx/WindowEx.cs#L81-L88
However I’m worried that the lack of window management APIs and
Titlecan’t even be set from XAML as we’re used to is going to be extremely off-putting to users. Is the amount of code you need to write acceptable, just to do basic management of your window, in a v1.0 release? (hint: I don’t think the answer isn’t yes).I’m worried people will take one look at WinUI and see that basic window management APIs are more or less non-existent (or as shown above overly complicated to use), and write off WinUI before it even had a chance.
Still broken in 1.0-experimental1. @marb2000 We’re not going to ship 1.0 with the inability to set the window title right? RIGHT? 😂
Still broken a year and a half later…
The ability to set the Title was added in WinAppSDK 1.3, but there was an issue with it. That issue has been fixed in 1.3.1 that is now available.
Just tried with the latest
v1.1.0-preview1and still doesn’t work. And to make matters worse, the error message is extremely unhelpful with no indication about what property or where:If you can’t fix it, at least fix the error message.
Don’t think this is getting fixed any time soon, now that there’s a workaround. 😞
The bug which could not die. <hopeful> Maybe in 1.1? </hopeful>
I had started writing WinUIEx as a temporary stop-gap to the lack of Windowing APIs, but hadn’t bothered completely finishing it up or publishing a nuget, because I naturally assumed basic Windowing APIs would be in 1.0, and I was also reluctant because the entire implementation just feels like one giant band-aid. It seems like I need to do bring this all the way to at least close some of these obvious gaps for 1.0.
Welp still not fixed. I think we’ll have to wait about at least 5 more years for this issue to be fixed cause apparently there are other 2.7k current open issues.
The docs have been updated (https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/stable-channel#version-131-13230502000). Thanks for the heads-up
@bpulliam Don’t you mean
v1.3.230502000? Congrats on 171000 builds in a month 😄Yeah I’m just saying that it’s probably gonna take a while to get it fixed. I’m using
this.Title =so no problem there. And while reading my own comment again, it does sound sarcastic and apologies for that. I guess I was a bit grumpy while I was writing that comment cause I haven’t slept all night on that day.@soobakjonmat I agree this is annoying. But it is by no means a showstopper like many other issues. You can still set it in code behind or use something like WinUIEx’s WindowEx to do it.
It’s still broken. I’m currently using the constructor method for temporary fix.
this.Title = "App Title";@ocalvo FYI, who was it that finished up the title bar work in winui3?