Microsoft .NET Trainingen

Reflection IT heeft een passie voor kennis delen en heeft zich ontwikkeld tot hét opleidingscentrum voor Microsoft Software Development trainingen.

Bekijk trainingen

Blog Artikelen

Using MVVM Design Pattern in Windows Forms

30-Dec-2023 1 Comments

The MVVM Design Pattern is mainly used in XAML enviroments like WPF, UWP, WinUI, Xamarin Forms and MAUI, because they support databinding between Controls and  Models but also between Buttons and Commands.

In .NET 8 it is possible to implement the MVVM Design Pattern in Windows Forms apps. It uses a new data binding engine which was in preview with .NET 7, and is now fully enabled in .NET 8. This new engine is modeled after WPF, which makes it easier to implement MVVM design principles. Time to write a blog post about it.

For this post I have written a simple demo Solution containing 3 projects. The ModelsLibrary project contains a ViewModel and is referenced by a Windows Forms and WPF project. I have published this solution in this GitHub repository

The UI of the Windows Forms and WPF apps are very simple. It shows the value of a Counter and has an Increment button to increment the value by 1. Simular to the Counter sample page of a Blazor app.

XAML NumberBox not accepting letters

04-Sep-2023

Last week there was a discussion on X (former Twitter) about the usage of the NumberBox in WinUI apps. Should it accept letter inputs or not. The 'conlusion' was that it should because you can enter formulas. But there are also a few developers which don't like this. So I took up the challenge to find a solution for this problem. My first guess was that I should create an AttachedProperty or Behavior for this. I was wrong. AttachedProperties can't be used for this. You can't use them for handing events on controls. Behaviors can but they require you to add an extra NuGet package to the project. Something you might not want. So I decided to use compiled binding (x:Bind) to events, also known as Event Binding.

System controls need BasedOn Styling in WinUI

26-Mar-2023

You can customize the appearance of your apps in many ways by using the XAML framework like WPF, UWP, WinUI and MAUI. Styles let you set control properties and reuse those settings for a consistent appearance across multiple controls. Styling is to XAML what CSS is to HTML. Using styles, you can group a set of properties and assign them to specific controls or all controls of a specific type, and just like in CSS, a style can inherit (BasedOn) from another style.

Starting with WinUI 2.6 there are new styles for most of the controls. It is encourage you to use the new styles, as they better match the design direction of Windows. You can read more about styling here

Reflection IT

Bij Reflection IT hebben we een passie voor kennis delen en zijn we hét opleidingscentrum voor Microsoft Software Development trainingen.

We ontwikkelen ook apps, omdat het leuk is en leerzaam. In deze apps kunnen we nieuwe Microsoft producten en technologieën toepassen, deze ervaring gebruiken we dan weer in onze trainingen.

Maak kennis met oprichter Fons Sonnemans en ons team van ervaren docenten, die ook allemaal developers zijn.

Fons Sonnemans

Proud of our customers

  • Actemium
  • ASML
  • Besi
  • Maastricht University
  • Microsoft
  • Promexx
  • Sioux
  • Topic
  • Topicus

Get in touch

Met dit formulier kunt u informatie over een In-Company of Small-Group training aanvragen. U kunt in het bericht aangeven welke training u wilt, voor hoeveel personen, wanneer deze verzorgd moet worden en op welke locatie. Wij nemen vervolgens contact met u op.

U kunt ons ook bereiken via telefoonnummer +31 (0)493-688810 of per mail training@reflectionit.nl.