KernelType Enumeration

Describes the kernel used to create the effect.

Namespace: System.Windows.Media.Effects
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:

public enum KernelType
public enum KernelType
public enum KernelType
<object property="EnumerationValue" .../>

 Member nameDescription
BoxA simple blur created with a square distribution curve.  
GaussianA distributed curve that creates a smooth distribution for a blur.  

This enumeration specifies the curve that is used to calculate the blur.

Performance Note: A Gaussian kernel creates a higher-quality blur but if performance is a concern, use the Box kernel because it uses less calculations.

The BlurBitmapEffect can be used to blur a visible object. Below are a series of examples that show the following:

  • How to use simple markup to apply the effect to an object

  • How to use a Style to apply the effect to one or more objects

  • How to use code to apply the effect to an object

  • How to use an animation to animate the properties of an effect applied to an object

Note: All of the examples below apply only a single effect to an object. To apply multiple effects, you can use BitmapEffectGroup. See How to: Create Multiple Visual Effects for examples.

The following example shows how to use a BlurBitmapEffect to create a blurry Button.

<Page xmlns=""

    <Button  Width="200">You Can't Read This!

      <!-- <BitmapEffectGroup> would go here if you wanted to apply more 
             then one effect to the Button. However, in this example only  
             one effect is being applied so BitmapEffectGroup does not need  
             to be included. -->

        <!-- The larger the Radius, the more blurring. The default range is 20.
             In addition, the KernelType is set to a box kernel. A box kernel
             creates less disruption (less blur) then the default Gaussian kernel. -->
        <BlurBitmapEffect Radius="10" KernelType="Box" />




The following illustration shows the effect created in the previous example.

Screenshot: Blurred button using BlurBitmapEffect

The following example shows how to use a Style to apply a BlurBitmapEffect to any Button on the page while it is pressed.

<Page xmlns=""

  <!-- Resources define Styles for the entire page. -->

    <!-- This style applies to any Button on the page. -->
    <Style TargetType="{x:Type Button}">

        <!-- When the Button is pressed, apply the blur. -->
        <Trigger Property="IsPressed" Value="true">
          <Setter Property = "BitmapEffect" >
              <BlurBitmapEffect Radius="10" />


    <!-- The Style defined above applies to this Button which makes
         the Button appear blurred while it is pressed. -->
    <Button Width="200" >Blurning down the House!</Button>



The following example shows how to use code to apply a BlurBitmapEffect to a Button when it is clicked.

The following is Extensible Application Markup Language (XAML) for the example.

<Page xmlns=""
  x:Class="SDKSample.BlurExample" >

    <Button Click="OnClickBlurButton" Width="200">Click to Blur!</Button>

The following code example is the code that handles the event for the Extensible Application Markup Language (XAML).

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Input;
using System.Windows.Media.Effects;

namespace SDKSample

   public partial class BlurExample : Page

      // Add Blur effect.
      void OnClickBlurButton(object sender, RoutedEventArgs args)
         // Toggle effect
         if (((Button)sender).BitmapEffect != null)
            ((Button)sender).BitmapEffect = null;
            // Get a reference to the Button.
            Button myButton = (Button)sender;

            // Initialize a new BlurBitmapEffect that will be applied
            // to the Button.
            BlurBitmapEffect myBlurEffect = new BlurBitmapEffect();

            // Set the Radius property of the blur. This determines how 
            // blurry the effect will be. The larger the radius, the more
            // blurring. 
            myBlurEffect.Radius = 10;

            // Set the KernelType property of the blur. A KernalType of "Box"
            // creates less blur than the Gaussian kernal type.
            myBlurEffect.KernelType = KernelType.Box;

            // Apply the bitmap effect to the Button.
            myButton.BitmapEffect = myBlurEffect;


The following example shows how to animate the Radius property of the BlurBitmapEffect to make the Button become blurry after it is clicked.

<Page xmlns=""
  xmlns:x="" >


    <Button  Width="200">
      Click to Blur ME!

        <!-- This BitmapEffect is targeted by the animation. -->
        <BlurBitmapEffect x:Name="myBlurBitmapEffect"  Radius="0" />

        <EventTrigger RoutedEvent="Button.Click">

              <!-- Blur the Button and then animate back to normal. -->
               From="0" To="40" Duration="0:0:0.3"
               AutoReverse="True" />



Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0