我的问题与此类似:WPF Style with no target type?但问题是我的是附属财产:
<Style TargetType="Shape" >
<Setter Property="z:Zommable.Unscale" Value="StrokeThickness" />
</Style>
我的目标是:从 shape 派生的所有对象都必须具有附加属性 Zommable.Unscale 和一个值,但我找不到如何做到这一点。谢谢 !
我的问题与此类似:WPF Style with no target type?但问题是我的是附属财产:
<Style TargetType="Shape" >
<Setter Property="z:Zommable.Unscale" Value="StrokeThickness" />
</Style>
我的目标是:从 shape 派生的所有对象都必须具有附加属性 Zommable.Unscale 和一个值,但我找不到如何做到这一点。谢谢 !
与另一个问题没有区别。你将不得不做同样的事情。因此,对于从 Shape 派生的每个类,您都必须使用具有该 targettype 的 Style ,该 targettype 是基于您的样式和附加属性的样式。
所以会是:
<Style x:Key="basicStyle">
<Setter Property="z:Zommable.Unscale" Value="StrokeThickness" />
</Style>
<Style TargetType="{x:Type Ellipse}" BasedOn="{StaticResource basicStyle}">
<!-- ... -->
</Style>
<Style TargetType="{x:Type Rectangle}" BasedOn="{StaticResource basicStyle}">
<!-- ... -->
</Style>
<!-- ... -->