Weird Commands behavior

Jul 31, 2008 at 4:12 PM
Hey Everybody.

I'm kind of a newbie, so I appologize if the question is stupid.

I'm getting weird behavior in command registration - if the "CommandHandler" is declared in a "WorkItem", then the CABUI Framework, does not look for it in Parent.Command, but instead adds it to the current WorkItem commands. Meaning that when the event was suppose to be fired, MyWorkItem wasn't register to it.

public class MyWorkItem : WorkItem
{
...
    [CommandHandler("...")]
    public void foo(object, EventArgs)
}


When I created a Controller class, registered a handle from there, but added the controller from MyWorkItem::InitializeServices(), suddenly both foo & foo2
got called.

public class MyController: Controller
{
    [CommandHandler("...")]
    public void foo2(object, EventArgs)
}

public class MyWorkItem : WorkItem
{
...
    [CommandHandler("...")]
    public void foo(object, EventArgs)

    protected  override InitializeServices()
    {
       this.Parent.Services.AddNew<MyController>();
    }

}

What should I do ?
Should Commands be handled NOT in WorkItems ?
Should I hack the CABUI code to always register the event in the parent workitem (CommandStrategy::RegisterCommandHandlers)?
Any other suggestions ?

Thanks alot in advance
Yoav S.

P.S
I'm currently using the CABUI and not prism (I understood that the only difference was with the Workspaces.... hope it's right and I didn't bother the wrong discussion board...)
Jul 31, 2008 at 5:44 PM
Hi Yoav S,

There are more differences between the CompositeWPF (aka Prism) and CAB/SCSF than the Workspace (it's a totally different infrastructure), e.g. doesn't have WorkItems.

If your a newbie I would highly recommend the Smart Client Software Factory at http://www.CodePlex.com/SmartClient - it is a higher level than CAB and has code generators (guidance packages) to do the bulk of the work for you.

Once you create your SCSF application you will want to register your command handlers in the ModuleController.

I learned a great deal from the gurus in the Smart Client forum - I trust they'll help you get started!