I'm using Smart Client Software Factory 2008. In the module controller, I have code that creates a new child controller only if it hasn't been created, by doing something like the following:
Dim key = "Item-" + item.ID.ToString()
Dim childWorkItem = Me.WorkItem.WorkItems.Get(Of ControlledWorkItem(Of ItemWorkItemController))(key)
If childWorkItem Is Nothing Then
childWorkItem = Me.WorkItem.WorkItems.AddNew(Of ControlledWorkItem(Of ItemWorkItemController))(key)
Else
childWorkItem.Activate()
End If
Multiple items reuse the same key, so when that action is triggered, it shows the tab instead of creating a new instance of it. This works great.
However, there is one drawback. Once activated, I need to run a check within that item's presenter. So I need to call a method on the presenter. Is there a way to invoka a method on the presenter, or is there an event that runs on the view when the work item is activated? I'm not sure how to make that happen?
Thanks.
If you are using a
Smart Part
as your View you should be able to accomplish this using theIWorkspace.SmartPartActivated
event.This is how I have it setup in my project. I apologize, my code is all in C# but you should be able to apply it in VB relatively easily.
The
WorkItemController
class has theActivate
method setup like thisIn the ISmartPartView Presenter class you should be able to create a handler for the
SmartPartActivated
event like this:In the
workSpaceSmartPart_ActivatedHandler
event handler, you can check the SmartPart being activated and if its your ISmartPartView class you can run the desired code.