UPDATE: Silverlight 3 joins in the fun!

After my enormously successful WPF – Easy rounded corners for anything post(really!), I’ve had some questions about cropping corners of an image with its own transparency.

Since we’re using an OpacityMask, you can do far more than define basic on/off geometry.  There’s nothing stopping you using an image as part of the mask too…

  <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
      <TextBlock FontSize="128" HorizontalAlignment="Center" VerticalAlignment="Center">hello world!</TextBlock>
      <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
          <Border Name="mask" CornerRadius="20" Background="White">
                  <ImageBrush ImageSource="SampleAlpha.png" Stretch="UniformToFill"/>
          <Image Source="e:\Scribble\temp\SampleAlpha.png">
                  <VisualBrush Visual="{Binding ElementName=mask}"/>

Here’s the result:


Click here or the image above to try it out.  Notice as you resize the window the clipped corners maintain the same radius…

kick it