WPF window used by two modules?

Topics: Prism v1, Prism v2 - WPF 3.5
Nov 13, 2009 at 4:34 PM

I am creating a relatively simple project manager as a Prism learning exercise. The application is built around a collection of Project objects. Each Project has a Tasks property (a collection of Task objects).

There are two main views in the application, and each view is a separate Prism Module:

  • The Project View shows a Project and its Tasks.
  • The Calendar View shows all Tasks for all Projects that are due on a selected date.

In other words, Tasks are shown in each view. They are displayed on a WPF Toolkit DataGrid. 

My Task object has a Notes property (a collection of TaskNote objects). To see a Task's notes in either view, the user double-clicks a task on the DataGrid in the current view, and a dialog pops up with a list of notes for that task. And that's where my problem arises:

Since the dialog can be invoked from either module, where should it be located? I hate to put a copy of the dialog in each module--that sort of duplication has a code smell to it. Any suggestions at to where to put the Notes dialog? Thanks in advance.

Nov 13, 2009 at 8:05 PM

Hi

You can use the PopupRegionBehavior that comes with the RI to achieve what you are trying to do in a decoupled way. You can read more about it here.

Please let me know if this helps.

Damian Schenkelman
http://blogs.southworks.net/dschenkelman

Nov 13, 2009 at 8:20 PM
Edited Nov 16, 2009 at 8:17 PM

Thanks, Damian! It sounds like the exact solution that I am looking for.

For others researching this issue:

1) Note that the class that creates the behavior is called RegionPopupBehaviors.

2) Note also that there is a bug in Prism 2.0 that causes a popup region to throw an error if the region it contains has an items control, such as a DataGrid. The bug, and a suggested workaround, are discussed here.