WPF Basics

This page will tell you something more about Windows Presentation Foundation or WPF. WPF uses an xml based language called XAML (pronounced as Zammel). XAML syntax focuses upon defining the UI (user interface) for the Windows Presentation Foundation (WPF) and is therefore separate from the application code behind it.

Why should you use WPF for your applications? Well as said before, separate the design, user interface from the code. WPF uses XAML and that doesn't take so much space like win forms (less place on harddisk, in memory, less bandwidth, ...).

Usage

Open Microsoft Visual Studio (2008 or higher) and start a new WPF Project. You can also use Microsoft Expression Blend to create XAML design for WPF Projects.

Shapes

  • Ellipse
  • Line
  • Path
  • Polygon
  • Polyline
  • Rectangle
WPF Ellipse
<Ellipse
  Fill="#FFFFFF00"
  Height="75"
  Width="75"
  StrokeThickness="5"
  Stroke="#FF0000FF"/>
WPF Line
<Line
    X1="10" Y1="60"
    X2="150" Y2="60"
    Stroke="Black"
    StrokeThickness="4"/>
WPF Path
<Path 
	Stroke="DarkGoldenRod" 
	StrokeThickness="3" 
	Data="M 100,200 C 100,25 400,350 400,175 H 280" />
WPF Polygon
<Polygon
    Points="300,200 400,125 400,275 300,200"
    Stroke="Purple" 
    StrokeThickness="2">
    <Polygon.Fill>
       <SolidColorBrush Color="Blue" Opacity="0.4"/>
    </Polygon.Fill>
</Polygon>
WPF Polyline
<Polyline 
	Points="25,25 0,50 25,75 50,50 25,25 25,0" 
	Stroke="Blue" 
	StrokeThickness="10" />
WPF Rectangle
<Rectangle 
	Fill="Blue"
    Stroke="Blue"
    Width="145"
    Height="126" />