有没有办法在 Silverlight 4 中重用形状样式?
我正在尝试为路径(形状)创建资源样式,但是,当创建多个使用该样式的路径时,仅渲染第一个路径。
//In resources xaml
<clr:String x:Key="path">M 50,50 L 35,15 A 8,10 0 0 1 65,15z</clr:String>
<Style TargetType="Path" x:Key="pathStyle">
<Setter Property="Stroke" Value="Black">
</Style>
//in control xaml
<Grid>
<Path Style="{StaticResource pathStyle}" Fill="Blue" Data="{StaticResource path}" >
<Path Style="{StaticResource pathStyle}" Margin="60" Fill="Red" Data="{StaticResource path}">
</Grid>
只有上面 XAML 中的第一个 Path 才会被渲染。我读到这就是目前应该的样子。有没有什么办法可以通过非程序化的方法来解决这个问题?
I'm trying to create a resource Style for a Path (Shape), however, when creating several Paths that use the Style, only the first one is rendered.
//In resources xaml
<clr:String x:Key="path">M 50,50 L 35,15 A 8,10 0 0 1 65,15z</clr:String>
<Style TargetType="Path" x:Key="pathStyle">
<Setter Property="Stroke" Value="Black">
</Style>
//in control xaml
<Grid>
<Path Style="{StaticResource pathStyle}" Fill="Blue" Data="{StaticResource path}" >
<Path Style="{StaticResource pathStyle}" Margin="60" Fill="Red" Data="{StaticResource path}">
</Grid>
Only the first Path in the XAML above will be rendered. I've read that this is currently how it's supposed to be. Is there any way to overcome this issue in a non-programmatic method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想您会发现一条路径直接放置在另一条路径之上。尝试添加一些边距或将它们放置在堆栈面板中。
I think you will find that one Path is placed directly over the other. Try adding some margin or placing them in a stackpanel.