Posts

Quick fix for 'Unrecognized configuration section system.diagnostics' error in .NET apps

.NET can be used to create a variety of different types of app, coming with various technologies such as WPF and Windows Forms to help you create them. .NET apps support providing a .config file with the app that can be used to store various bits of configuration information about the app. There is an issue, however, that you might encounter when adding this file to your project (either manually or automatically, such as when you create a .settings file). The issue is that this file can cause a System.Configuration.ConfigurationErrorsException exception, with an error message that starts with something like 'Unrecognized configuration section system.diagnostics'. Luckily, there is an easy fix for this issue which simply involves adding a single line of code to your config file. The Fix So, to fix the issue, first open your project's configuration file (it will probably be named app.config or something like that) and add the following line under <configSections>: <

Desktop.ini: What is it, what can it be used for and what properties does it support?

Image
No doubt you've come across the mysterious 'desktop.ini' file before - especially if you often have hidden files set to show. But what exactly is this file? How can a seemingly empty folder end up with this file? What does it even do? Well, read on to find the answers to all those questions! What is desktop.ini? Desktop.ini is a basic text file that can often be found hidden in folders. Desktop.ini actually stores various properties and information about its parent folder for use by file browsers when displaying the folder. There are various things you can change about how the folder looks by using Desktop.ini, such as setting a ToolTip to display when the user mouses-over the folder or setting custom text to display when the folder is empty. Another use is to specify string resources to use for files in the folder - this allows for localisation, meaning that file names can appear different depending on your system's default language.  Another example is in our app QPad

WPF: How to enable shadows and rounded corners on ToolTips in Windows 11

Image
Windows 11 originally came out in 2021, however, an official Windows 11 theme has not yet been released for WPF (more on that here ). Because of this, WPF apps still have more of a Windows 8/10 look. Luckily, there are some easy things you can do to modernise your WPF user interfaces . You could of course, create your own custom styles, however this can take quite a bit of work. This article covers something that can be done easily, without much work and without breaking compatibility with older operating systems. Enabling shadows and rounded corners on ToolTips WPF presents its ToolTips in seperate top level windows. This allows them to easily show on top of other content and not be limited to the size and position of its parent window. Windows 11 includes a built in feature as part of the DWM (Desktop Window Manager) that rounds top level windows. You can control this feature using the DwnSetWindowAttribute Windows function. Using this function, we can tell Windows 11 to have the DW

WPF: How to detect if a mouse event was raised by a mouse, touch or stylus/pen input

Image
If you've ever tried to detect if a given input was caused by mouse, touch or stylus/pen, you've probably noticed that it seems easy at first - WPF provides events for mouse, touch and stylus/pen input so just use those to detect what type of input was used right? Well unfortunately it's not as simple as that - see, for compatibility reasons, touches also raise stylus/pen events and mouse events in addition to touch events and stylus/pen input also raises mouse events in addition to stylus/pen events. This means that mouse events can be caused by mouse, touch or stylus/pen input and stylus events can be caused by stylus/pen input and touch input. Luckily, the arguments passed into mouse events can be used to detect if it was caused by mouse, touch or stylus/pen input, though, finding this information can be difficult if you don't know where to look. How to detect if a mouse event was raised by mouse, touch or stylus/pen input One of the arguments passed into mouse event