Silverlight: Bug with RadialGradientBrush OpacityMask
.NET,
Silverlight,
Technical stuff
See comments
Update: Just posted this at http://silverlight.net/forums/t/6486.aspx
I stumbled upon a bug in Silverlight today related to the way it handles OpacityMasks with a RadialGradientBrush.
Try the following code:
<Canvas Background="Red" Canvas.Top="0" Canvas.Left="0" Width="320" Height="240"> <Canvas.OpacityMask> <RadialGradientBrush> <GradientStop Offset="0" Color="#FF000000"/> <GradientStop Offset="1" Color="#00000000"/> </RadialGradientBrush> </Canvas.OpacityMask> </Canvas> <Rectangle Fill="Red" Canvas.Top="0" Canvas.Left="320" Width="320" Height="240"> <Rectangle.OpacityMask> <RadialGradientBrush> <GradientStop Offset="0" Color="#FF000000"/> <GradientStop Offset="1" Color="#00000000"/> </RadialGradientBrush> </Rectangle.OpacityMask> </Rectangle>
This code uses the same RadialGradientBrush as OpacityMask in a Rectangle and in a Canvas. However, when you run that code into Silverlight (I have the latest version installed, V1.1.20926.0), you get the following picture:

Note that running the exact code in a WPF window creates the following scene, which is correct:
