Zum Hauptinhalt springen

Data Binding to Visibility Property

The following describes how to used a converter to directly bind your ViewModel properties to the Visibility of controls in your view. First we define a converter that converts a boolean value into a Visibility enum value and back. [ValueConversion(typeof(bool), typeof(Visibility))] public class VisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, […]

ViewModel Validation in MVVM

In WPF IValidatableObject, IDataErrorInfo interface implementations can be used to validate user input against validation rules. This blow shows a different approach that defines a IValidatingViewModel as interface for ViewModels that should use a validation. This is a very simple approach without relying on some black box third party technology. Validation Interface This is the […]

Using Data Annotations for Validation in WPF

The .NET Framework uses many different approaches for validation. The ASP.NET MVC for example uses Data Annotations to annotate the model classes with the definition of valid ranges, etc. In WPF on the other hand, validation rules are used to validate entries made by the user and display error messages. This post shows how to […]

Model-View-ViewModel (MVVM) Introduction

This post gives you an overview of the MVVM (Model-View-ViewModel) pattern. There are many similar very good articles like this, giving you a rough overview, historical background and/or nitty-gritty details on the pattern. Here I’d like to show you the very basics of the MVVM. Consider this as my personal view. Many of the other […]