How we can disable parent window while popup window is open?

Sep 16, 2011 at 7:31 PM

Hi,
How we can disable parent window while popup window is open?

 please see the link:
http://blog.wpfwonderland.com/2010/03/23/use-the-wpf-blur-effect-to-focus-attention/

how to implement  with MVVM(catel) ?


For example, using the code below-

    private void OnDelete()
        {
             var messageService = GetService<IMessageService>();
            if (messageService.Show("Are you sure you want to remove this person?", "Are you sure?", MessageButton.YesNo) == MessageResult.Yes)
            {
               
             
             
                AllCustomers.Remove(SelectedCustomer);
            }
        }

Coordinator
Sep 16, 2011 at 8:34 PM

Fair question. Currently, only the PleaseWaitWindow supports such behavior, but I will implement it in a separate helper class so it can be re-used.

Coordinator
Sep 16, 2011 at 9:56 PM

I have implemented a special helper class called EffectsHelper. The PleaseWaitHelper already uses the Blur mode as default.

If you want this behavior, you will need to do the following things:

1) Derive a new class from MessageService

2) Override the Show(string, string, MessageButton, MessageImage) method like this:

public override MessageResult Show(string message, string caption, MessageButton button, MessageImage icon)
{
	EffectsHelper.Blur();
	
	var result = base.Show(message, caption, button, icon);
	
	EffectsHelper.Unblur();
	
	return result;
}

3) Register the new service manually (in app.xaml.cs onstartup):

Catel.IoC.ServiceLocator.Instance.RegisterType<IMessageService, YourNewClass>();

 

It should all work as you planned :)

Sep 17, 2011 at 7:47 PM

Thanks for your solution.... :)


But  [EffectsHelper.Blur();] this is a  Extension Method
public static void Blur(this FrameworkElement frameworkElement);


I could not understand how it works In those place(Derive a new class from MessageService) 

 you call with out parameter ,like a simple method...can you explain more about the EffectsHelper.Blur

Coordinator
Sep 18, 2011 at 5:04 AM

Hmmm, I must have been sleeping or something. You need to decide what window(s) you want to blur. Probably, you want the main window, but maybe all application windows? Below are the solutions.

1) Main window

System.Windows.Application.Current.MainWindow.Blur();

2) All windows

foreach (Window window in System.Windows.Application.Current.Windows)
{ 
    window.Blur();
}

Sep 18, 2011 at 8:26 AM

 

Hi thanks a lot for offering to help this is great :)


 public class MessageServiceHelper : Catel.MVVM.Services.MessageService
    {
        public override MessageResult Show(string message, string caption, MessageButton button, MessageImage icon)
        {

         
            System.Windows.Window parent = System.Windows.Application.Current.GetActiveWindow();
            parent.Blur();
            var result = base.Show(message, caption, button, icon);
            parent.Unblur();
            return result;
        }
    }

Coordinator
Sep 18, 2011 at 2:55 PM

You are welcome! If you have more feature requests or bugs reports, just let us know!

Thanks for posting the final solution.