WPF V3.5 Sp1 and Effects – A Bit of an Embarrassing Gaffe

Update ( 30/09/08 ) : I had this wrong at least twice. I’ve tried to fix it now.

When it comes to WPF V3.5 Sp1, I’ve been showing people a lump of XAML to demonstrate the improvements in effects rendering and I think I’ve just realised today that I’ve been showing them the wrong XAML file.

Now, on the one hand this is a bad thing in that I’ve been showing people the old effects by mistake.

On the other hand this is a good thing because it turns out that I was showing them the new effects without realising it.

I seem to remember in the past that if I did something like this;

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Grid>  
   <MediaElement Source="c:\users\mtaulty\desktop\liquid.wmv">
    <MediaElement.BitmapEffect>
     <BlurBitmapEffect Radius="{Binding ElementName=mySlider,Path=Value}"/>
    </MediaElement.BitmapEffect>
   </MediaElement>
   <Slider x:Name="mySlider" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="10" MinWidth="192" Minimum="0" Maximum="10"/>
  </Grid>
</Page>

then the performance would be “not so great” and you’d really notice.

Today, on WPF V3.5 Sp1 that gives fine performance because it’s quitely “migrated” to using the new effects that you should really use as below. This is only for Blur/DropShadow as those are the only 2 new bundled effects;

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Grid>  
   <MediaElement Source="c:\users\mtaulty\desktop\liquid.wmv">
   <MediaElement.Effect>
    <BlurEffect Radius="{Binding ElementName=mySlider,Path=Value}"/>
   </MediaElement.Effect>
   </MediaElement>
   <Slider x:Name="mySlider" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="10" MinWidth="192" Minimum="0" Maximum="10"/>
  </Grid>
</Page>

In case you’re wondering, “c:\users\mtaulty\desktop\liquid.wmv” is a hi-def 1080p move that I got from here.

One way that you can force the use of the “old effects” is that you can wrap a BitmapEffectGroup around the BitmapEffect for a Blur/DropShadow and you’ll see a less performant set of effects.