Faced a problem when writing a style, I want something to move on to any of the rectangles; the picture (block1) + would change transparency ; if I use a rectangle in the code, everything works fine, and in the style it gives an error:
The TargetName property cannot be set for the Style Setter type.
<Window.Resources> <Style TargetType="Rectangle"> <Style.Triggers> <EventTrigger RoutedEvent="MouseEnter"> <BeginStoryboard> <Storyboard TargetName="block1" TargetProperty="Margin" > <ThicknessAnimation From="-750,0,750,0" To="-200,0,200,0" Duration="0:0:0.7" DecelerationRatio="0.6"/> </Storyboard> </BeginStoryboard> <BeginStoryboard> <Storyboard TargetName="block1" TargetProperty="Opacity" > <DoubleAnimation To="0.8" Duration="0:0:0.4"/> </Storyboard> </BeginStoryboard> </EventTrigger> <EventTrigger RoutedEvent="MouseLeave"> <BeginStoryboard> <Storyboard TargetName="block1" TargetProperty="Opacity" > <DoubleAnimation To="0" Duration="0:0:0.1"/> </Storyboard> </BeginStoryboard> <BeginStoryboard> <Storyboard TargetName="block1" TargetProperty="Margin" > <ThicknessAnimation To="-450,0,450,0" Duration="0:0:0.7"/> </Storyboard> </BeginStoryboard> </EventTrigger> </Style.Triggers> </Style> </Window.Resources> 