Binding to database in View

Topics: Bootstrappers & IoC, Getting Started
Jun 25, 2011 at 10:44 PM

What is the best event to call my PopulateItemsFromDatabase method?

I have it in the VM constructor and it works but I feel like it is not the right place.  And for some reason OnActivate is not firing!!!

Jun 26, 2011 at 8:49 AM

Lifecycle methods (OnInitialize, OnActivate) are intended to support authonomous setup task of the VM (data loading included).
In particular, OnInitialize should better fit loading tasks because it is called just once, when the VM is activated for the first time; OnActivate, instead, could occur several times during the VM lifetime.

The real problem, then, is to get the OnActivate method called :-)
Make sure that your VM is held by a Conductor (or a quasi-conductor), which is responsible of enforcing the conducted VM(s) lifecycle through the call of lifecycle methods with the opportune timing.