This is not going to be easy. You are going to modify the look not of your window, but the whole desktop with the application window which has nothing to do with your application and, hence, nothing to do with WPF.
Nevertheless, there is a work around. You have to copy the whole desktop image and then create your own WPF window which covers all the background and mimic it. This background window should be a separate top-level window with the property
WindowStyle
set to
System.Windows.WindowStyle.None
:
http://msdn.microsoft.com/en-us/library/system.windows.window.windowstyle%28v=vs.110%29.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.windows.windowstyle%28v=vs.110%29.aspx[
^].
It will allow you creating a window without any
non-client area, to cover all the current desktop to mimic the desktop appearance. In this window, you need to draw the graphic copied from the "real" desktop, blurred or the way you want.
There are many ways to capture the screen. You can search a solution on the Web.
You can also look at the source code of this open-source project:
http://sourceforge.net/projects/screencapturewp[
^].
To create some blur effect (there are way to many different kinds of blur, including very realistic but hard to calculate
boke), you can use
convolution matrix:
http://en.wikipedia.org/wiki/Kernel_%28image_processing%29[
^].
The article reference above shows three sample kernels for blur. You can create something else. This kind of transformation can be done in WPF or
System.Drawing.Bitmap
(which you can obtain from screen copy and will need to transform to a WPF bitmap). You can access bits of any of those bitmaps by yourself and perform the convolution. Only don't use prohibitively slow
GetPixel/SetPixel
, instead use
LockBits
(
System.Drawing
) or, with WPF, the class
WriteableBitmap
:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.lockbits%28v=vs.110%29.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap%28v=vs.110%29.aspx[
^].
If it seems to difficult for you, you can use, for example, open-sourse AForge.NET library, its
Convolution
class,
Blur
class, in particular,
GaussianBlur
:
http://www.aforgenet.com/framework/docs/html/3b7d8422-2d79-8019-8933-a0472040c124.htm[
^],
http://www.aforgenet.com/framework/docs/html/be5cfa72-caa1-205b-d282-9abe2fc1c19b.htm[
^],
http://www.aforgenet.com/framework/docs/html/f074e0dd-865c-fd5f-ba0a-80e336a0eaea.htm[
^].
You can also use any matrix of your choice.
On top of this "fake background", you can put the WPF content you need. There are many small things to solve. For example, when you click in the "fake background" window, you need to "get back to normal". You need to remove this window and activate the "real" window behind it. And so on…
Sorry that my solution is a bit schematic. It really takes good deal of knowledge to figure out all the pieces you need. If you don't feel scared by the volume of this work, you can try to start and ask further questions as you go.
—SA