Blend Behaviors + DependencyPropertyDescriptor = Memory Leak

Thursday, March 14, 2013

In the past couple of weeks, I was taking part in a focused effort to find and fix memory-related issues in one of my client's applications. In this post I want to write about a specific type of memory leak that I found more than once, which is related to Blend-behaviors. As an example, consider the following behavior: 1: public class MyMarginDependentBehavior : Behavior<FrameworkElement> 2: { 3: private readonly DependencyPropertyDescriptor...
no comments

Kona – The ViewModelLocator Class

Saturday, January 26, 2013

In previous posts I mentioned how, by using the Binding markup extension, the view automatically resolves its bounded properties from a view model object that is stored in its DataContext property. How the view model ends up being referenced in the view's DataContext property was left to be some kind of magic. In this post I will talk about the component that is responsible for making this happen – the ViewModelLocator. Before diving into the details, let's re-set the context. We have a simple view model with a single property, named FirstName: ...
no comments

Kona – The BindableBase Class

Sunday, January 20, 2013

In the previous post I mentioned that the view's bounded controls can be updated automatically when the view model's properties to which they are bounded changes, given that the view model raises a specific event. In this post I want to elaborate on that, and walk you through the relevant implementation in Kona. The INotifyPropertyChanged Interface To provide change notification to the view's data bound controls, the view model should implement the INotifyPropertyChanged interface, which contains a single event called PropertyChanged, and raise that event whenever a property changes. The following example shows how the PropertyChanged...
no comments

Kona – Commands

Friday, January 18, 2013

The first thing I will cover in the series about Kona is the good old DelegateCommand class, that all of the Prism veterans learned to respect. But first, a quick overview for those of you who never worked with commands before. Why do we need commands for? One of the corner stones of MVVM is clear separation of the view from the view model. Those two components should be as loosely coupled as possible and interact only by using binding. To accomplish this separation, the view model exposes it's data with properties, and the view presents and...
no comments