Reputation: 1618
I'm working on following code .. of course, the solution gets built and compiles all that but when I hit F5 or start I get following error message.
Cannot convert the value in attribute 'Style' to object of type 'System.Windows.Style'. Can only base on a Style with target type that is base type 'Rectangle'. Error at object 'System.Windows.Shapes.Rectangle' in markup file
This is the code:
<Style x:Key="Connector1" TargetType="Rectangle" BasedOn="{StaticResource Style123}">
<Setter Property="Fill" Value="Aqua" />
</Style>
<Style x:Key="Connector1_DragThumb" TargetType="Rectangle" BasedOn="{StaticResource Style123}">
<Setter Property="IsHitTestVisible" Value="true"/>
<Setter Property="Fill" Value="Yellow"/>
<Setter Property="Stroke" Value="Black"/>
</Style>
Any help is appreciated.
Regards.
Upvotes: 0
Views: 402
Reputation: 57939
The error suggests that StaticResource Style123
on which you are basing this style does not itself have TargetType="Rectangle"
.
You can only base a Rectangle
style on another Rectangle
style or a base class thereof (or the default by using {StaticResource {x:Type Rectangle}}
).
Upvotes: 1