<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 可以会有多种形状