参考自:http://www.cnblogs.com/evangelion_yu/archive/2009/05/21/WPFintro.html
1、开发工具:vs2008
2、新建工程:
new->file->project->WPF Application 取名HelloWorld。
3、工程中插入图片:
点击工程HelloWorld右键->Add->Existing Item,选择图片。
4、新建User Control:
点击工程HelloWorld右键->Add->New Item,选择WPF->User Control;将UserControl1.xaml和UserControl1.xaml.cs加入工程。
5、自定义User Control:
UserControl1.xaml文件如下:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="HelloWorld.UserControl1"
x:Name="UserControl"
Width="30" Height="200">
<Grid x:Name="LayoutRoot">
<Rectangle Margin="0,9,0,8.5">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="-1.741,0.747" StartPoint="3,0.16">
<GradientStop Color="#FFDDDB15" Offset="0"/>
<GradientStop Color="#FFFF0000" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Ellipse VerticalAlignment="Top" Height="15">
<Ellipse.Fill>
<LinearGradientBrush EndPoint="-1.741,0.747" StartPoint="3,0.16">
<GradientStop Color="#FFDDDB15" Offset="0"/>
<GradientStop Color="#FFFF0000" Offset="1"/>