How to Create Irregular Shape Controls Silverlight


To draw the irregular shape objects in Silverlight we can use the Polygon and Path. Polygon has multiple points separated by space. Using these points we can draw any shape. The other option is the path. Using path its easy to draw a curve and irregular objects.

Below XAML will draw two objects.

<UserControl
 xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation
 xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml
 xmlns:ed=”http://schemas.microsoft.com/expression/2010/drawing
 x:Class=”SilverlightApplication1.MainPage”
 Width=”640″ Height=”480″ >

 <Grid x:Name=”LayoutRoot”>
  <Grid.Background>
   <LinearGradientBrush EndPoint=”0.5,1″ StartPoint=”0.5,0″>
    <GradientStop Color=”Black” Offset=”0″/>
    <GradientStop Color=”#FF4B1818″ Offset=”1″/>
   </LinearGradientBrush>
  </Grid.Background>
  <Polygon Points=”40,100 40,200 200,200 200,130 150,100″ Fill=”Orange”></Polygon>
  <Path Data=”M415,57 L413,143 L483,142 L484,76 L454,56 z” Fill=”#FFF4F4F5″ Margin=”0,131.5,30.5,38.5″ Stretch=”Fill” Stroke=”Black” UseLayoutRounding=”False” HorizontalAlignment=”Right” Width=”282″/>
  
 </Grid>
</UserControl>

ScreenShot

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s