WPF中的画图

1、border(边框):
      <Border BorderBrush="Blue" BorderThickness="0,1,1,1" Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2"/>

    其中2个重要属性:BorderBrush画笔颜色和BorderThickness画笔边框(左上右下)宽度

2、Path(路径):

      <Path Data="M0,0 L0,20" Stretch="Fill" Stroke="#FF606060" HorizontalAlignment="Left" Width="1" Margin="20,5,0,0" />

  主要属性:Data标识开始点和结束点,stretch标识填充方式,stroke标识填充的颜色;

  • (1) 直线:Line(L)
  • (2) 水平直线: Horizontal line(H)
  • (3) 垂直直线: Vertical line(V)
  • (4) 三次方程式贝塞尔曲线: Cubic Bezier curve(C)
  • (5) 二次方程式贝塞尔曲线: Quadratic Bezier curve(Q)
  • (6) 平滑三次方程式贝塞尔曲线: Smooth cubic Bezier curve(S)
  • (7) 平滑二次方程式贝塞尔曲线: smooth quadratic Bezier curve(T)
  • (8) 椭圆圆弧: elliptical Arc(A)
  • (9)M绝对坐标,m相对坐标

扩展:

path的使用:

      <Path Stroke="Gold" StrokeThickness="3">
            <Path.Data>
                <PathGeometry>
                    <PathFigure StartPoint="200,200">
                        <PathFigure.Segments>
                            <LineSegment Point="200,400"></LineSegment>
                            <LineSegment Point="400,400"></LineSegment>
                            <LineSegment Point="400,200"></LineSegment>
                            <LineSegment Point="200,200"></LineSegment>
                        </PathFigure.Segments>
                    </PathFigure>
                </PathGeometry>
            </Path.Data>
        </Path>

Border:用来编辑背景图片

<Button>
    <Border>
         <Image Source="Images/HomePageImages/关闭图标.png" Height="18" Width="18"/>
      </Border>
</Button>

自定义控件的使用:(有点题外话了,但学习在于汇总和总结,愿与你共进步)


 3、补充知识:编程颜色转化
btnname.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00a49d"));

 4、主动调用Button按钮Click事件:(btnwxAllOrder为Button按钮的名称,调用wpf 路由事件)
btnwxAllOrder.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Primitives.ButtonBase.ClickEvent, btnwxAllOrder));

原文地址:https://www.cnblogs.com/xibei666/p/4377610.html