使用 WPF 制作 公章,主要使用到的知识点有:缩放变换,旋转变换的知识。下面附上xaml代码。

<Grid > <!--背景图片,可有可无--> <Grid.Background> <LinearGradientBrush> <GradientStop Color="Blue" Offset="0"/> <GradientStop Color="yellow" Offset="0.5"/> <GradientStop Color="Red" Offset="1"/> </LinearGradientBrush> </Grid.Background> <Grid.Resources> <!--定义label的样式--> <Style TargetType="{x:Type Label}"> <Setter Property="RenderTransformOrigin" > <Setter.Value> <Point X="0.5" Y="2.5"/> </Setter.Value> </Setter> <Setter Property="Width" Value="56"/> <Setter Property="Height" Value="50"/> <Setter Property="FontSize" Value="30"/> <Setter Property="Foreground" Value="#ffff0000"/> <Setter Property="VerticalAlignment" Value="Top"/> <Setter Property="RenderTransform"> <Setter.Value> <TransformGroup> <ScaleTransform ScaleX="0.6" ScaleY="1"/> <!--绑定到Tag上,用于旋转的角度--> <RotateTransform Angle="{Binding Tag,RelativeSource={RelativeSource AncestorType=Label}}"/> </TransformGroup> </Setter.Value> </Setter> </Style> </Grid.Resources> <!--外侧圆圈--> <Ellipse Margin="0,1,0,0" Height="250" Fill="{x:Null}" Stroke="#FFFF0000" x:Name="EllipseBorder" HorizontalAlignment="Center" VerticalAlignment="Top" Width="250" StrokeThickness="1"/> <!--中间的五角星--> <Path StrokeThickness="1.000000" Stroke="{x:Null}" Fill="#FFFF0000" Data="F1 M 55.467773,1.628906 L 68.130859,40.893066 L 109.385742,40.802734 L 75.957031,64.979004 L 88.791016,104.187500 L 55.467773,79.865234 L 22.144531,104.187500 L 34.978516,64.979004 L 1.549805,40.802734 L 42.804688,40.893066 L 55.467773,1.628906 Z" HorizontalAlignment="Center" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Center"> <Path.RenderTransform> <TransformGroup> <ScaleTransform ScaleX="0.68" ScaleY="0.68"/> <SkewTransform AngleX="0" AngleY="0"/> <RotateTransform Angle="0"/> <TranslateTransform X="0" Y="0"/> </TransformGroup> </Path.RenderTransform> </Path> <!--下面是一堆文字和角度--> <Label Content="我" Tag="10"/> <Label Content="是" Tag="30"/> <Label Content="一" Tag="50"/> <Label Content="只" Tag="70"/> <Label Content="快" Tag="90"/> <Label Content="乐" Tag="110"/> <Label Content="的" Tag="130"/> <Label Content="小" Tag="150"/> <Label Content="黄" Tag="170"/> <Label Content="鸭" Tag="190"/> <Label Content="黄" Tag="210"/> <Label Content="黄" Tag="230"/> <Label Content="黄" Tag="250"/> <Label Content="黄" Tag="270"/> <Label Content="黄" Tag="290"/> <Label Content="黄" Tag="310"/> <Label Content="~" Tag="330"/> <Label Content="~" Tag="350"/> </Grid>

大致效果已经出来了,其它美化就要你们自己动手啦~

效果图:

wpf边框发光效果(wpf制作公章圆形环绕字)(1)

,