The Databinding feature in Microsoft Expression Blend 3 allows this interaction without the need to write one of code.