//XAML语法 <Path Name="path_M" Fill="LawnGreen" Data="M 0 0 L 100 0 L 100 100 L 0 100"></Path> //cs事件中语法 //点击按钮,让之前画的正方形变成一个长方形(重点是:Geometry.Parse这个赋值规则) private void button_Click(object sender, RoutedEventArgs e) { path_M.Data = Geometry.Parse("M 0 0 L 100 0 L 100 400 L 0 400"); }