Fork me on GitHub
The journal that this archive was targeting has been deleted. Please update your configuration.
« Behavior Event | Main | View »


A Behavior (B) is a command-like class that can be executed by the Controller (C) against a specific View Model (VM) to retrieve and persist data or just transition a View (V) to another View (V). There are 3 types of Behaviors: Transition Behaviors (TB), Data Behaviors (DB), and Hybrid Behaviors (HB). Transition Behaviors are dynamically bound to a specific View (V), when executed would cause the current View (V) to hide and the bounded View to be rendered as the next visible View. Data Behaviors when executed against a specific View Model would interact with the actual data and keep the View Model in sync with the data. Hybrid Behaviors like the name suggests they are both Transition Behaviors and Data Behaviors; they keep the data and the View Model in sync and at the same time transition the current View to the bounded View.
public partial class OpenStudentProfileBehavior
    public override void Execute(
        BehaviorEvent<StudentViewModel> behaviorEvent)
        StudentEntity entity;
        var id = behaviorEvent.ViewModel.Id;
        // find from database
        using (var data = new EntityModelContainer())
            entity = data.StudentEntities.First(s => s.Id == id);

        // translate data to ViewModel
        behaviorEvent.ViewModel =
            new StudentViewModel()
                    Id = entity.Id,
                    FirstName = entity.FirstName,
                    LastName = entity.LastName,
                    Email = entity.Email


Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>