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 […]
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 […]
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 […]
WPF – ProgressBar
In this simple example, we will see how to create and manipulate the ProgressBar control from WPF in a MVVM way. Let’s start with the View in XAML: And now the ViewModel: Happy coding! 🙂
C# – Enum Color Converter with IValueConverter
With WPF, it’s pretty easy to create a converter to display the color of a text depending on an Enum value. Here is a simple example with IValueConverter. Let’s start with the View: As you can see, we use a converter to select the correct color. Here is the code for this converter: The color […]
WPF – ItemsControl and TemplateSelector
Let’s say that you want to create your UI but in a dynamic way. Imagine a view which is based on a list of items you want to display. But this list can vary (depending on rights, or context). In this simple example, we want a label with a textbox, then a checkbox. We can do […]
WPF – Paste Clipboard content from Excel to a GridView
Hello Devz, Manipulating the clipboard content is pretty easy. But it can become handy when pasting it in a GridView. Here a simple example on how to paste the content of the clipboard from Excel to a GridView. First things first! Here is how to use the clipboard: var clipboardContent = Clipboard.GetText(); Obviously you could use […]
WPF – MVVM TextBox Validation with IDataErrorInfo
Hello Devz, This post will describe how to do a simple MVVM TextBox validation with IDataErrorInfo. UI Data Validation is an important part of the FrontEnd creation. The FrontEnd should always be backed up by the BackEnd validation! But here we will focus only on the FE part. Before showing the code, you have to […]
WPF – Enum Binding With Description in a ComboBox
Hello Devz, In my two previous posts, I was talking about how to bind an enum (the classic way and the other way). But these have two major issues. First, all the items from the Enum will be bound and displayed. And sometimes you don’t want to display all of them (like ‘None’). Secondly, you […]
WPF – Enum Binding in a ComboBox – The Other Way
Hello Devz, In a previous post I was talking about the fact that there is no “out-of-the-box” solution to bind an Enum to a ComboBox. And I described the WPF way of doing it with the ObjectDataProvider defined in the XAML. Here is another way, more code oriented than XAML. This is the XAML part: […]