View (as SmartPart) Initialization

Topics: Mobile Client Software Factory
Nov 3, 2006 at 2:11 PM
originally posted by: herocomplex

Since the Compact Framework doesn't have a Load event for UserControls, how the heck do you initialize any work it needs to do, such as filling a datagrid on load? Do I need to explicitly call a public method on it after I show it? I guess that just feels silly. Thanks all.
Nov 3, 2006 at 4:14 PM
originally posted by: dcazzulino

If you use the OrientationAwareControl as a base class, you will find quite useful the Load event and its corresponding OnLoad virtual method ;)

It basically works just like the desktop counterpart: called whenever the owning form is loaded.
Nov 7, 2006 at 8:05 AM
originally posted by: herocomplex

That is EXACTLY what I needed. Thanks!

Strangely, the Load event won't fire. I can step through the code to verify that the event IS being registered, it just doesn't ever get called. I've also tried overriding OnLoad, nothing. I guess I'll add the OrientationAwareControl source so I can step through it, but this seems pretty strange.

I'm using the OAC as a view that is being added to a Workspace as a WindowSmartPart. Example below.

myOACView = Items.AddNew<MyOACView>();
this.shell.MainWorkspace.Show(myOACView , new WindowSmartPartInfo());

This would be because the Owning Form has already been loaded, right? In the desktop environment, there doesn't need to be a parent form for the control's Load event to fire. Can the OAC not fire its Load unless its parent is Loading?