Geometry.Parse方法

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");
        }

效果:
Geometry.Parse方法_第1张图片
Geometry.Parse方法_第2张图片

你可能感兴趣的:(Geometry.Parse方法)