首页 新闻 会员 周边

silverlight4 中 path 的style 问题

0
悬赏园豆:50 [已关闭问题] 关闭于 2012-09-27 01:31

<StackPanel>
  <StackPanel.Resources>
  <Brush x:Key="ItemStroke">#FFD69436</Brush>
  <LinearGradientBrush x:Key="ItemBrush" StartPoint="0,0" EndPoint="0,1">
  <LinearGradientBrush.GradientStops>
  <GradientStop Color="#FAFBE9" Offset="0" />
  <GradientStop Color="Orange" Offset="1" />
  </LinearGradientBrush.GradientStops>
  </LinearGradientBrush>
    
  <Style x:Key="FlowChartItemStyle1" TargetType="Path">
  <Setter Property="Fill" Value="{StaticResource ItemBrush}"/>
  <Setter Property="Stroke" Value="{StaticResource ItemStroke}"/>
  <Setter Property="StrokeThickness" Value="2"/>
  <Setter Property="StrokeLineJoin" Value="Round"/>
  <Setter Property="Stretch" Value="Fill"/>
  <Setter Property="IsHitTestVisible" Value="False"/>
  </Style>
    
  <Style x:Key="Process" TargetType="Path" BasedOn="{StaticResource FlowChartItemStyle}">
  <Setter Property="Data" Value="M 0,0 H 60 V40 H 0 Z"/>
  </Style>
  </StackPanel.Resources>
  <Path Style="{StaticResource Process}" Width="40" Height="40"/>
  <Path Style="{StaticResource Process}" Width="40" Height="40"/>
</StackPanel>

请问为何只有第一个path 能显示出来,而第二个path 就不显示呢?

如果将Path 的 Data 直接赋值如下:
  <Path Data="M 0,0 H 60 V40 H 0 Z" Style="{StaticResourceFlowChartItemStyle}" Width="40" Height="40"/>
  <Path Data="M 0,0 H 60 V40 H 0 Z" Style="{StaticResourceFlowChartItemStyle}" Width="40" Height="40"/>

然后使用样式FlowChartItemStyle ,则两个Path 都能显示。可是这样就太不灵活了,难道Path 的Data 不能放在样式里吗?
因为我的Path 可以会有多种形状

‰流浪※的主页 ‰流浪※ | 初学一级 | 园豆:132
提问于:2011-03-14 17:19
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册