Felice Pollano
Felice Pollano

Reputation: 33262

Styling an attached property with inheritance

My question is similar to this: WPF Style with no target type? but the problem is that mine is an attached property:

<Style TargetType="Shape" >
    <Setter  Property="z:Zommable.Unscale" Value="StrokeThickness" />
</Style>

My goal is: all object deriving from shape must have the attached property Zommable.Unscale with a value, but I can't find how to do it. Thanks !

Upvotes: 1

Views: 267

Answers (1)

Markus H&#252;tter
Markus H&#252;tter

Reputation: 7906

there is no difference to the other question. you will have to do exactly the same. So for each class deriving from Shape you will have to use a Style with that targettype that's BasedOn your style with your attached property.

So it's gonna be:

<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>

<!-- ... -->

Upvotes: 1

Related Questions