Skip to main content

WPF – ShowDialog on top of the Main Window


Hi devz, While using a Microsoft.Win32 Dialog (OpenDialog or SaveDialog), it is possible that it will be opened behind the Main Window. So a good way to go back on that dialog is to use the ALT+TAB combo. But not really intuitive for the end user. The best way would be that this dialog is […]

C# – Open an already opened file


Let’s say you want to open an Excel file by code but this Excel file is already opened by another user on another machine on a file share… You might encounter this issue: The process cannot access the file because it is being used by another process. But you still can open this file in […]

C# – Parse String Hour to TimeSpan or DateTime


Converting a String to something else can always be tricky. Especially if that String is about time. The thing is the fact that there are many ways to represent time and that can actually depend on the country you are. 6 PM, 6.00 PM, 06.00, 06:00, 18:00, 18h00, 18H00, they could be all the same. […]

WPF – OpenFileDialog


This is a simple example to have an OpenFileDialog (a premade view done by Windows to select a file to open) with WPF, filtering on XLSX file: In this case the InitialDirectory will always exist because it is the Desktop of the current user. But you have to know that if the targeted InitialDirectory doesn’t […]

C# – AutoMapper Configuration Tutorial

automapper logo

What is AutoMapper? AutoMapper is a C# library which allows to do the mapping automatically between two similar objects. Typically really useful to map for example a domain model to a DTO (Data Transfer Object) or from a UI model to other layers of your code. Why should you use AutoMapper? Of course you always […]

C# – How to use Serilog


There are many log libraries on NuGet, but I would say the 3 most known ones are NLog, Log4Net and Serilog. This article will focus on Serilog with a simple example of how to start with it. Why should you use Serilog? Serilog is a powerful library allowing you to create logs for your application […]

C# – Read Settings from the AppSettings.json

appsettings json

You might be used to the good old web.config or app.config file. But if you upgrade your solution to something a bit more modern like .Net 5, then it will be transformed to appsettings.json. Here are some tips about how to use the appsettings.json. The app.config file was stored as an XML file. So you […]

C# – Upgrade Your Solution To .Net

upgrade .Net Framework to .Net

This article will talk about how you can easily upgrade your .Net Framework solution to .Net 5 (6, Core, Standard). Microsoft released a simple dotnet script to do this painful task for you. Currently the tool supports the following .NET Framework app types: .NET Framework Windows Forms apps .NET Framework WPF apps .NET Framework ASP.NET […]

WPF – ContentControl and TemplateSelector


Here is a simple example about the ContentControl and the TemplateSelector. This is really useful when you have a single model that can be represented on the UI in different ways depending on an enum for example. This will be the final result in the UI while using the same model: Let’s start with our […]

C# – BDD Tests with xBehave and xUnit


In this post we will see the basics of BDD with xUnit and xBehave. But not only! If you don’t know what are: BDD, Gherkin, integration tests, Cucumber, SpecFlow, xUnit or xBehave, read the following sections. Otherwise, just skip straight to a simple example of an integration test with C# based on xBehave and xUnit. […]