Posts

Showing posts with the label WPF

How to embed an image into your WPF application

If you are building an WPF application you could need images as background or as buttons or whatever. With your  first build or debug you will see the images will be stored in a folder that should not change. If you change it the application cannot find its images and crashes. So if your installing this application you will need to make sure the pictures are in the exact place. There are possibilities to make the path of the path dynamic, but even that is not the best solution.  So how to make sure your files will be where your application will be.  The solution is to embed the images, but how..? Of course there are some hacks you need to know. First of all you need to right click on your project in Visual Studio. Go to "Properties" and then "Resources". Add a resource and choose existing file. Choose your image.

How to support multiple languages in WPF

Image
If you are developing many solutions for many costomer, one day one of them will require a multilingual WPF-solution. So there is the question: how to make a WPF form multilingual? At first you need at least two languages that you want to support. You can add some other languages at the end very easy. First of all create a folder in your project and call it "Languages", to keep an overview. Once it is done you can create Resource Dictionaries in this folder. You can call them however you want, but make sure you can assign them to the language. You can use language codes (like "en-us") or you can call it like the language is called. At the end it can look like this:

Refreshing the UI in WPF

If you are using WPF and missing the 'Application.DoEvents();' method, you know from Windows Forms to refresh the UI, here is a solution for you. I had the same problem and was looking for a way to refresh the UI in runtime.