Geometry.Parse方法

来源:互联网 发布:万宝路黑冰爆珠淘宝 编辑:程序博客网 时间:2024/06/06 12:16

Geometry.Parse方法

将一个字符串转化成Geometry对象

举例:在WPF程序中刷新一条线段上的点:
example.xaml中:

<Path x:Name="ecg" Stroke="Red" Data="M 220,0 C 230,0 70,100 200,100 S 470,0 200,0"  Margin="0,0,0,0" Stretch="Fill"></Path><Button x:Name="button" Content="Button" Grid.Column="1" HorizontalAlignment="Left" Height="22" Margin="199.2,117.2,-170.4,0" Grid.Row="1" VerticalAlignment="Top" Width="132" Click="button_Click"/>

example.xaml.cs中:

        private void button_Click(object sender, RoutedEventArgs e)        {            ecg.Data = Geometry.Parse("M 0, 200 Q 100, 0 200, 200 Q 300, 400 400, 200");        }

效果:
Before
After