Introduction:
WPF is stand for Windows Presentation
Foundation provides an unified model for producing high end graphical business
application easily using normal XML syntax (known as XAML) which runs both in
client and server leveraging the job to render output more relying on graphics
devices rather than using GDI components. It uses Direct3D rendering which
employs graphics cards to render the output on the screen. Thus the drawing in
the form will be smooth and also there is a chance to utilize the hardware
capabilities installed in your machine. In case of traditional GDI forms
application it is not possible to use advanced graphics capabilities and hence
Windows Forms application will always be inefficient in comparison to WPF.
Another important thing that I must address in this regard, GDI Windows forms
application uses Operating system controls to build its application. Thus it is
basically very hard to customize them in your own application. WPF controls are
actually drawn over the screen and hence you can customize controls totally and
modify their behavior when required.
Some Features of WPF:
- New Property System & Binding Capabilities
- Resource based Approach for every control
- Redefine Styles and Control Templates
- Built-In Support for Graphics and
Animation
Example: simple design a button in WPF.
Code
<Window
x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow"
Height="350"
Width="525">
<Grid>
<Button
Content="X"
Height="19"
HorizontalAlignment="Right"
Margin="0,3,4,0"
Name="button_close"
VerticalAlignment="Top"
Width="20"
FontFamily="Courier"
FontWeight="Bold"
Style="{StaticResource
{x:Static
ToolBar.ButtonStyleKey}}"
FontStretch="Normal"
Visibility="Visible"
FontSize="14"
Padding="0"
ToolTip="Close"/>
<Label
Content="Open"
Height="55"
HorizontalAlignment="Left"
Margin="42,64,0,0"
Name="label_TabTitle"
VerticalAlignment="Top"
FontFamily="Courier"
FontSize="12"
Width="116"
Background="#FFE10064" />
<Label
Background="#FFE100C8"
Content="Dispose"
FontFamily="Courier"
FontSize="12"
Height="55"
HorizontalAlignment="Left"
Margin="243,64,0,0"
Name="label1"
VerticalAlignment="Top"
Width="116"
/>
<Label
Background="#FFE1C864"
Content="Close"
FontFamily="Courier"
FontSize="12"
Height="55"
HorizontalAlignment="Left"
Margin="150,160,0,0"
Name="label2"
VerticalAlignment="Top"
Width="116"
/>
</Grid>
</Window>

Summary: Now in this example we have
design a more then one button using a WPF tools. Before set a properties of
button we have take grid control on a WPF form after that under the grid control
we have set the all button properties. I hope above example help to you how to
create a button in a WPF application.