Silverlight XAML Primer 5, Listing 2

Simulating a 3D surface using radial gradients within an XAML canvas.

<Canvas xmlns="http://schemas.microsoft.com/client/2007">

 <!-- Outside ellipse -->
 <Ellipse Height="525" Width="525" Stretch="Fill" Stroke="Black">
  <Ellipse.Fill>
   <RadialGradientBrush Center=".5,.5">
    <GradientStop Color="White" Offset=".97"/>
    <GradientStop Color="Gray" Offset="1"/>
   </RadialGradientBrush>
  </Ellipse.Fill>
 </Ellipse>

 <!-- Internal blue ellipse -->
 <Ellipse Width="500" Height="500" Fill="#FF02027a" Stroke="Black" 
  
 StrokeThickness="2" Canvas.Left="12" Canvas.Top="12" />

 <!-- Lighting effect on internal blue ellipse -->
 <Ellipse Width="300" Height="350" Canvas.Left="35" Canvas.Top="-25">
  <Ellipse.Fill>
   <RadialGradientBrush RadiusX="2" RadiusY="2" Center="0.5,0.5">
    <GradientStop Color="#55FFFFFF" Offset="0"/>
    <GradientStop Color="Transparent" Offset="0.25"/>
   </RadialGradientBrush>
  </Ellipse.Fill>
 </Ellipse>

</Canvas>

comments powered by Disqus
Most   Popular
Upcoming Events

.NET Insight

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.