Applying Pixel Shaders and Effects

Pixel shaders enable you to add effects to Silverlight controls by modifying the pixels of their rendered output before displaying them on the screen. Typical effects include shadows, blurs, reflections, and color alteration, but the options are almost endless.

There are two pixel shaders included in the Silverlight 5 runtime:

  • DropShadowEffect
  • BlurEffect

Applying one of these effects is an easy as assigning the pixel shader to the Effect property of a control. The following example demonstrates assigning a drop shadow to a control, with the result shown in Figure 9-2:

<Button Content="Shadow" Width="75" Height="23">     <Button.Effect>         <DropShadowEffect Opacity="0.5" />     </Button.Effect> </Button> ...

Get Pro Business Applications with Silverlight 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.