It's always a good thing to personalise applications we make, especially when there is a graphical user interface.
The idea here is to change the default icon of your C# application with Visual Studio.
We also use the Gimp software to create the .ico file.
So let's get started.
We will use for this tutorial:
Create the icon you want.
It's better to set a size of 48 pixels (width and height).
Then File > Export > Write the name you want, for example badprog-icon-48.ico (be sure to specify the .ico extension at the end of the name) > Export > Export (don't touch the options).
You ICO file is ready!
Right click your project name (not the Solution name) > Properties > Resources > Add Resource > Add Existing File... > Select your icon (badprog-icon-48.ico).
Then still from the project properties > Application > Icon and manifest > Icon: > select the badprog-icon-48.ico file > Save your project.
Click F5 to launch your Debug, the application has opened but without any personal icon.
Why?
Because this is certainly a Microsoft bug.
But don't worry your icon is linked with your application.
To see it, you have to look in your project folder, you should see your application with your own icon!
To see it directly on your application window, double click your application from this folder.
A solution exists to have the icon directly with the debug mode.
Let's admit you have put ICO files into the SOLUTION/PROJECT/Resources folder.
Open your XAML file, for example MainWindow.xaml > Click inside the code > F4.
The XAML properties should open.
Open the Common tab > Icon > Select the icon of your choice.
You should see inside the XAML file a new line like that in the <Window> markup:
Icon="pack://siteoforigin:,,,/Resources/badprog-icon-48.ico"
Now you have to copy/paste the Resources folder into the SOLUTION/PROJECT/bin/Debug folder.
Click F5, you should see your icon, even in the Debug mode!
You have now the first step to customise your C# applications.
Great job, you've made it.
Comments
StrangerNeko (not verified)
Sunday, March 18, 2018 - 1:53am
Permalink
About missing icon inside app
About missing icon inside app: it's not a bug, you just need to set Icon property of your form.
Add new comment