WPF - how and why
Written by Ian Elliot   
Saturday, 25 July 2009
Article Index
WPF - how and why
Why WPF?
No XAML WPF
Layout controls
Graphics
Buttons on the edge

 

Banner

Graphics

WPF is also a full graphics system and you can draw either in XAML or in code almost anything you want.

For example to draw a line:

<Line
Stroke="Black"
StrokeThickness="10"
X1="10"
Y1="10"
X2="75"
Y2="90"/>

An Ellipse is as easy:

<Ellipse
Height="100"
Width="200"
Fill="Yellow"
Stroke="Black"
Canvas.Left="175"
Canvas.Top="50"
StrokeThickness="2" />

You can also draw polylines, i.e multiple connected line segments:

<Polyline
 Points="25,25 0,50 25,
  75 50,50 25,25 25,0"
Stroke="Blue"
StrokeThickness="10"
Canvas.Left="75"
Canvas.Top="50">
</Polyline>

You can also create smooth curves fitted to a set of points using Bezier curves but this is a little more complicated – see the documentation.

WPF also supports a wide range of sophisticated fills including gradient and bitmap fills. For example to create a linear gradient fill:

<Rectangle Width="200"
Height="100">
<Rectangle.Fill>
<LinearGradientBrush
StartPoint="0,0"
EndPoint="1,1">
<GradientStop
Color="Yellow"
Offset="0" />
<GradientStop
Color="Blue"
Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>

graphics

WPF is a complete 2D graphics package

<ASIN:0735619573>

<ASIN:1590599497>



Last Updated ( Friday, 19 March 2010 )
 
 

   
RSS feed of all content
I Programmer - full contents
Copyright © 2014 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.