Path Markup Syntax in WPF
I use this code to define two quarter cir开发者_JAVA技巧cles:
<Grid Width="300" Height="300" Margin="50" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Path Name="Test1" Stroke="Black" StrokeThickness="5" s:Contacts.ContactDown="Test1_PreviewContactDown" s:Contacts.PreviewContactDown="Test1_PreviewContactDown" Data="M25,0 A25,25 90 0 1 50,25 l-25,0 Z" Fill="Orange" Grid.Row="0" Grid.Column="1" Stretch="Fill"/>
<Path Name="Test2" s:Contacts.ContactDown="Test2_PreviewContactDown" s:Contacts.PreviewContactDown="Test2_PreviewContactDown" Data="M50,25 A25,25 90 0 1 25,50 l0,-25 Z" Fill="Red" Grid.Row="1" Grid.Column="1" Stretch="Fill" />
<Ellipse Fill="Transparent" Stroke="Black" Grid.ColumnSpan="2" Grid.RowSpan="2"/>
<Ellipse Fill="White" Stroke="Black" StrokeThickness="5" Width="100" Height="100" Grid.ColumnSpan="2" Grid.RowSpan="2"></Ellipse>
</Grid>
Now I'd like to extend this code, so that instead of two quarter circles with cover half a circle, I'd like to have 6 circle segments which each 30 degrees. How can I do that? I wasn't really able to understand the Path Markup Syntax.
I agree with VoodooChild above that your best bet is to use a visual designer like Expression Blend. You can get a free trial from Microsoft. You can just make the path you want and copy the generated XAML into whatever page you are authoring.
Also, doing a little googling, I found this:
http://marlongrech.wordpress.com/2008/01/10/jasema-the-xamlpadx-plugin-for-building-path-geometry/
Which looks like a free Path builder plugin for XAMLPadX. I haven't tried it myself, but suffice to say that there is no magical easy way to make Paths in WPF without using a tool.
精彩评论