New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to change the title bar icon for a winui 3.0 app #1914
Comments
Hi @MarkvanWinkelen, you can change the title bar icon using the AppWindow APIs. Here's an example... // Get the AppWindow from the XAML Window ("this" is your XAML window)
IntPtr hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
WindowId myWndId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(hWnd);
var appWindow = AppWindow.GetFromWindowId(myWndId);
// And then set the icon
appWindow.SetIcon("yourIconPath"); In the future we're going to work on better integrating the AppWindow APIs with the XAML Window so you can more easily use all the great functionality that's within AppWindow without writing those 3 lines of verbose code! Here's the feature request for that item: Integrate AppWindow with WinUI 3. |
It's worth mentioning that |
GetWindowHandle expects a window, not a page. |
Ah, well, that makes sense and when run with the window from App.OnLaunched() it works. Thanks for the help! |
And also I'm getting the same cast exception. Where did you make the above changes? Can you please help me by posting the screenshot or code? |
Regarding App Title - it can be set under MainWindow.xaml.cs, under public MainWindow add a line for: |
I am unable to change the title bar icon for my packaged winui 3.0 app. It is possible to change the title bar title, to in my case 'Koraalbewerkingen'. Can you make it possible to change the icon as easy as the title is changed in C#?
The text was updated successfully, but these errors were encountered: