.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> WPF >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Make parent window blured for better focus on UI , in WPF

Posted By:Manas Patnaik       Posted Date: December 09, 2010    Points: 75    Category: WPF    URL: http://www.dotnetspark.com  

This post is about UI experience for your application in WPF .In products we come across situations where a user often mishits for a modal form over a parent form.Either they realize once they click on form or upon the warning message.Here a visible inactive/shadowed background window can make user task easy ,that describes some other dialog need attention first.This concept is not new and we can find it in so many websites while showing images etc..(For Example check the Images in my blog and o
 

This post is about UI experience for your application in WPF .In products we come across situations where a user often mishits for a modal form over a parent form.Either they realize once they click on form or upon the warning message.Here a visible inactive/shadowed background window can make user task easy ,that describes some other dialog need attention first.This concept is not new and we can find it in so many websites while showing images etc..(For Example check the Images in my blog and observe the back ground).

Here in this post we will replicate the scenario in win form application using inbuilt effect of WPF , BlurEffect .As shown in image bellow.

ManasPatnaik Blog

Well to achieve the functionality the following piece of code required.
Code Snippet
/// 
/// Apply Blur Effect on the window
/// 
/// 
private void ApplyEffect(Window win)
{
System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect();
objBlur.Radius = 4;
win.Effect = objBlur;
}
/// 
/// Remove Blur Effects
/// 
/// 
private void ClearEffect(Window win)
{
win.Effect = null;
}


And check the code we need to call before showing any modal dialog.
Code Snippet
private void btnShowDialog_Click(object sender, RoutedEventArgs e)
{
WinModalDialog objModal = new WinModalDialog();
objModal.Owner = this;
ApplyEffect(this);
objModal.ShowDialog();
ClearEffect(this);
}

So BlurEffect Class in System.Windows.Media.Effects is a bitmap effect that blurs the screen/control.Here in above code the instance of blur effect is assigned to the windows effect property.Bitmap effects are simple pixel processing operations uses bitmap sources and apply effects on it.

Download the source code Download
 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend