Blur Effect with BlurBitmapEffect


   
 

<Window x:Class="BitmapEffectsExample"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="Bitmap Effects" Height="500" Width="400">
    <!-- : -->
    <StackPanel Margin="5" Grid.Column="1" Grid.Row="0">
      <Button Content="A Blur Button" Width="175" Height="50"
        Margin="5">
        <Button.BitmapEffect>
          <BlurBitmapEffect Radius="1" />
        </Button.BitmapEffect>
      </Button>
      <Button Content="A Blur Button" Width="175" Height="50"
        Margin="5">
        <Button.BitmapEffect>
          <BlurBitmapEffect Radius="3" />
        </Button.BitmapEffect>
      </Button>
    </StackPanel>

</Window>

   
     


Glowing Effect with OuterGlowBitmapEffect


   
 

<Window x:Class="BitmapEffectsExample"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="Bitmap Effects" Height="500" Width="400">
    <StackPanel Margin="5,20,5,5" Grid.Column="0" Grid.Row="1">
      <Button Content="A Growing Button" Width="150" Height="30" Margin="10">
        <Button.BitmapEffect>
          <OuterGlowBitmapEffect GlowColor="Gray"
            GlowSize="15" Noise="1" />
        </Button.BitmapEffect>
      </Button>
      <TextBlock Text="Growing" FontSize="40" FontWeight="Bold"
        Foreground="White" Margin="5">
        <TextBlock.BitmapEffect>
          <OuterGlowBitmapEffect GlowColor="Gray"
            GlowSize="10" Noise="0.5" />
        </TextBlock.BitmapEffect>
      </TextBlock>
    </StackPanel>

</Window>

   
     


Embossed Effect with EmbossBitmapEffect


   
 

<Window x:Class="BitmapEffectsExample"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="Bitmap Effects" Height="500" Width="400">

    <StackPanel Margin="5,10,5,5" Grid.Column="0" Grid.Row="2">
      <TextBlock Text="Original Image" Margin="5" />
      <Image Width="175" Source="c:image.jpg" Margin="5"
        Grid.Column="0" Grid.Row="2" />
      <TextBlock Text="Embossed Image" Margin="5" />
      <Image Width="175" Source="c:image.jpg" Margin="5">
        <Image.BitmapEffect>
          <EmbossBitmapEffect Relief="0.5" LightAngle="320" />
        </Image.BitmapEffect>
      </Image>
    </StackPanel>

</Window>
    

   
     


Shadow Effect and DropShadowBitmapEffect


   
 

<Window x:Class="BitmapEffectsExample"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="Bitmap Effects" Height="500" Width="400">
    <!-- : -->
    <StackPanel Margin="5,20,5,5" Grid.Column="1" Grid.Row="1">
      <Button Content="A Shadow Button" Width="150" Height="30"
        Margin="5">
        <Button.BitmapEffect>
          <DropShadowBitmapEffect ShadowDepth="10"
            Color="DarkRed" />
        </Button.BitmapEffect>
      </Button>
      <TextBlock Text="Shadow" Margin="3,0,3,13" FontSize="40"
        FontWeight="Bold" Foreground="LightCoral">
        <TextBlock.BitmapEffect>
          <DropShadowBitmapEffect ShadowDepth="20"
            Color="Gray" Softness="0" />
        </TextBlock.BitmapEffect>
      </TextBlock>
    </StackPanel>

</Window>

   
     


A Beveled Button and TextBlock with BevelBitmapEffect


   
 

<Window x:Class="BitmapEffectsExample"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="Bitmap Effects" Height="500" Width="400">
    <StackPanel Margin="5" Grid.Column="0" Grid.Row="0">
      <Button Content="A Beveled Button" Width="175" Height="50"
        Margin="5">
        <Button.BitmapEffect>
          <BevelBitmapEffect BevelWidth="10"
            EdgeProfile="CurvedIn" LightAngle="45" Relief="0.2"
            Smoothness="0.5" />
        </Button.BitmapEffect>
      </Button>
      <TextBlock Text="Bevel" FontSize="65" FontWeight="Bold"
        Foreground="DarkRed">
        <TextBlock.BitmapEffect>
          <BevelBitmapEffect />
        </TextBlock.BitmapEffect>
      </TextBlock>
    </StackPanel>

</Window>

   
     


Property changed callback


   
  
<Window x:Class="WpfApplication1.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="Window1" Height="300" Width="300">

    <StackPanel>
      <TextBox x:Name="uv" Text="{Binding Path=UserValue, UpdateSourceTrigger=PropertyChanged}" 
               />

    </StackPanel>

</Window>


//File:Window1.xaml.cs
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace WpfApplication1
{
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
            DataContext = this;
        }
        private static void UserValue_PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Window1 window1 = d as Window1;

            if (window1 != null)
            {                
                window1.uv.Foreground = Brushes.SeaGreen;
            }
        }
    }
}

   
    
     


Manual Update Target


   
  


<Window x:Class="WpfApplication1.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="clr-namespace:WpfApplication1" 
  Title="ManualUpdateTarget" Height="135" Width="200">
  <Window.Resources>
    <local:Person x:Key="Tom" Name="Tom" Age="11" />
  </Window.Resources>
  <StackPanel DataContext="{StaticResource Tom}">
    <TextBlock Margin="5" VerticalAlignment="Center">Name:</TextBlock>
    <TextBox Margin="5" Name="nameTextBox" Text="{Binding Path=Name}" />
    <TextBlock Margin="5" VerticalAlignment="Center">Age:</TextBlock>
    <TextBox Margin="5" Name="ageTextBox" Text="{Binding Path=Age}" />
    <Button Margin="5" Width="75" Name="birthdayButton">Birthday</Button>
  </StackPanel>
</Window>

//File:Window.xaml.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.ComponentModel;

namespace WpfApplication1 {
  public class Person {
    string name;
    public string Name {
      get { return this.name; }
      set {
        if( this.name == value ) { return; }
        this.name = value;
      }
    }

    int age;
    public int Age {
      get { return this.age; }
      set {
        if( this.age == value ) { return; }
        this.age = value;
      }
    }

    public Person() { }
    public Person(string name, int age) {
      this.name = name;
      this.age = age;
    }
  }

  public partial class Window1 : System.Windows.Window {
    public Window1() {
      InitializeComponent();
      this.birthdayButton.Click += birthdayButton_Click;
    }

    void birthdayButton_Click(object sender, RoutedEventArgs e) {
      Person person = (Person)this.FindResource("Tom");
      person.Age = person.Age+1;
      BindingOperations.GetBindingExpression(ageTextBox, TextBox.TextProperty).UpdateTarget();

      Console.WriteLine(person.Name);
      Console.WriteLine(person.Age);
    }
  }
}