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.
The error suggests that
StaticResource Style123on which you are basing this style does not itself haveTargetType="Rectangle".You can only base a
Rectanglestyle on anotherRectanglestyle or a base class thereof (or the default by using{StaticResource {x:Type Rectangle}}).