tags:

views:

34

answers:

1

Hi everybody!

I 'm running currently into a situation for which i cannot find a solution:

In a WPF application i 'm opening several user controls in a tabcontrol. So every tabitem has different things loaded(e.g. customer,supplier, article, warehouse,...).

In the customer tabitem i want to delete the selected customer, so i want a pop up to show up with a confirmation "do you want to delete the customer?" which is MODAL to THIS tabitem, letting the user the possibility to select another tabitem eg. the supplier. The user can select the supplier tabitem where she can do whatever she wants,... but coming back to the customer tabitem she still sees the dialog box.

How can this be implemented using MVVM techniques?

Thanks in advance

+2  A: 

Make the "modal window" a UserControl. Have it's visibility tied to a property in the ViewModel.

You can then place the UserControl in the grid along with the tab content, but with a higher Z-index. When the property is swapped to true in the VM, the "modal window" UserControl will become visible, and completely cover the tab content. This prevents any manipulation within that tab, without preventing the tab switching.

This, BTW, is a similar technique to the one Josh Smith used in Advanced MVVM for all of his dialogs. (There are some definite differences, since he wasn't dealing with tabbed items, etc... but the core concept is the same.)

Reed Copsey
+1. You can see similar concept in BBShack sample app (Look when items are added) http://karlshifflett.wordpress.com/2010/02/07/bbq-shack-ocean-v2-for-visual-studio-2008/
Eduardo Molteni
@Reed:makes perfect sense!Thanks!What i 'm not sure about is:do i have to "prepare" a usercontrol for *each* of the following facilities: deleting, canceling, saving,... do you understand what i mean? that many? Consider that i have 50 different entities to administer this would be somehow ... inefficient. I think i miss something...
Savvas Sopiadis