How do I link (dependency) properties in my ViewModel?

Posted by mos on Stack Overflow See other posts from Stack Overflow or by mos
Published on 2010-06-16T22:09:26Z Indexed on 2010/06/16 22:12 UTC
Read the original article Hit count: 162

Filed under:
|
|
|

Simplified example:

I have an object that models a user. Users have a first name and a last name. The UserViewModel has a dependency property for my Models.User object. In the declaration of the UserView's xaml, I want to bind a couple of TextBlocks to the first and last name properties.

What is the correct way to do this? Should I have readonly DependencyProperties for the name fields, and when the dependency property User is set, update them? Can the name fields be regular C# properties instead? Or, should I bind like this:

<TextBlock Text="{Binding User.FirstName}" />

© Stack Overflow or respective owner

Related posts about wpf

Related posts about Silverlight