-
Notifications
You must be signed in to change notification settings - Fork 143
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
The icon isn't displayed correctly in the title bar #111
Comments
Thank you for reporting this issue. And sorry for the late reply. I tried to reproduce this with different .ico files but couldn't achieve the effect you had. For me, all icons I tried look the same in both window classes. Would you mind uploading your file here so I can use it for reproduction? |
I sent you an email with my icon. I hope this will be useful to you. |
@benruehl I have the same problem. ICO file attached: ZenTimings.ico.zip As a workaround I've commented this line out, recompiled the DLL and defined a separate 16x16 icon for the MainWindow
That doesn't work, because now the taskbar (when "use small taskbar buttons" is witched off) is using the same 16x16 icon from the MainWindow. |
Ok guys, good and bad news. Good news: Bad news: At the moment, I use I found a different approach here which looked promising but unfortunately this throws a Last thing I found was some ugly interop magic here. This is a lot of code for such a simple requirement but I tested it anyway. It didn't work though. I cannot say why because there is no exception raised or anything. The rendered icon simply becomes a generic placeholder icon. Possible workaround: public MainWindow()
{
InitializeComponent();
// Try to get your icon in the correct size here and assign it.
IconSource = GetIcon("pack://application:,,,/AdonisUI.Demo;component/ZenTimings.ico", 16);
}
private ImageSource GetIcon(string iconSource, double width)
{
var decoder = BitmapDecoder.Create(new Uri(iconSource),
BitmapCreateOptions.DelayCreation,
BitmapCacheOption.OnDemand);
var result = decoder.Frames.SingleOrDefault(f => f.Width == width);
if (result == default(BitmapFrame))
{
result = decoder.Frames.OrderBy(f => f.Width).First();
}
return result;
} You can try different methods of loading an icon if you want. I linked some resources that might help. |
Yes, that approach works for me. Thanks! PS: For other child windows I'm already using a separate 16x16 optimized PNG file. |
Good to hear that this works for you :) I will close this issue then although the solution does not feel really satisfying to me. |
Thanks @benruehl for all your research! I found another workaround (if we can call it that), instead of setting the icon in the XAML file, just set it in the app properties: Project > Properties > Application tab. |
@DonKadaj This is my usual way of setting the application icon, but it did not work - it didn't matter if it is defined in the project properties or in the XAML file. GetApplicationIcon() gets this icon and extracts the 32x32 image from it. |
@irusanov Make sure to remove the |
@DonKadaj That's how I have it from the beginning and the higher resolution of the icon is loaded. |
Describe the bug
I use an ico file (which embed several icon sizes) for my application logo. Usually, Windows chooses the best size to display. However, with
AdonisUI.Controls.AdonisWindow
the size isn't adjusted in the title bar.Screenshots
![image](https://user-images.githubusercontent.com/54101733/87871397-3c38bd80-c9b0-11ea-98e6-bf4a6e771aac.png)
![image](https://user-images.githubusercontent.com/54101733/87871452-afdaca80-c9b0-11ea-92cb-166379946fc7.png)
The icon displayed from
Windows
:The icon displayed from
AdonisUI.Controls.AdonisWindow
(it uses an oversized icon):The text was updated successfully, but these errors were encountered: