* You are viewing the archive for the ‘.NET’ Category

Datagrid: support for grouping on columns use IValueConverters to display their value and conditonal rowstyling

DataGrid update

Introduction

Some further enhancements have been made to the DataGrid wrapper that has been the subject of this previous post:

  • Support for grouping on columns that use IValueConverter to display their value
  • Conditional row styling

This post is a code drop for these enhancements.

Conditional row styling

The following code gives a sample on how to use conditional row styling:

public MainPage()
{
InitializeComponent();

theDataGrid.ItemsSource = PersonFactory.GetAllPersons();

theDataGrid.RowStyles.Add(new MyDataGridRowConditionalStyle(
(o) => { return ((Person)o).Name.Contains(“A”); },
Continue Reading

Postponing actions

Introduction

Often modifications to an object (setting properties or calling methods etc.) cause synchronization actions to be executed. For instance, adding a SortDescription to an ICollectionView object can cause the object to perform a sorting operation on the items it contains. When multiple modifications to an object are made, it is desirable to postpone these synchronization actions until all modifications are made.

This blog presents the PostponableAction class with which this kind of behavior can be implemented. This idea is based on and can be used as an implementation to the DeferRefresh method of the ICollectionView interface.

Table of … Continue Reading

INotifyPropertyChanged: automatic dependent property and nested object support

Summary

The hardest problem with INotifyPropertyChanged is often overlooked: dependency management. When one property is changed, all of its dependent properties need to fire as well.

This blog presents another solution based on dynamic dependency determination.

Table of contents

INotifyPropertyChanged implementations: An Overview

Summary

One of the cornerstones of MVVM is the INotifyPropertyChanged interface. This post describes several implementations that have been used/proposed over time.

Table of contents

Introduction

One of the cornerstones of MVVM is the INotifyPropertyChanged interface. This post describes several implementations that have been used/proposed over time.

The basic ingredient of each INotifyPropertyChanged implementation is the … Continue Reading

Passing parameters to a Silverlight XAP application

In this post two ways to pass parameters to an in-browser Silverlight application without modifying the XAP are described:

  • Using the querystring of the containing HTML/ASP.NET page
  • Using the InitParams attribute of the object tag that hosts the XAP file

The first method is straight forward: just add a querystring to the URL. You can retrieve the querystring using the HtmlPage.Document like this (based on code from MSDN):

private void Application_Startup(object sender, StartupEventArgs e)
{
Page p = new Page();
this.RootVisual = p;

// This assumes that Page.LayoutRoot exists and is a StackPanel.
Continue Reading

Code generators for generating strongly typed resource classes for Visual Studio 2010

Guy Smith Ferrier created some code generators for use with Silverlight. Unfortunately, as noted by Don Ruiter these generators do not install in Visual Studio 2010. In this blog he outlines the steps to modify the installer to work with Visual Studio 2010.

Because he did not post the resulting installer, I have performed these steps myself. The resulting installer can be downloaded here.

Update

As can be read here Guy Smith Ferrier has updated his downloads, so the resulting installer can be downloaded here too.

Determining leaked objects

A while back I noticed that Pochet.NET was suffering from a memory leak, probably caused by some event handlers that were not properly removed. Although I had a hunch about what objects were leaking, I was not quite sure. That is why I decided to create the MemoryLeakDetector helper class. The sole purpose of this class is to keep track of how many instances of a specific type are active (i.e. not garbage collected).

This class can be used in the following ways: you can use the MemoryLeakDetector as the base class, like this:

public class MyClass : MemoryLeakDetector
{
Continue Reading