1

I have a MouseOver event for a border. Within that border (further down) I have a couple of Borders with RotateTransforms... How can I, within the top level Border hover event alter their transform? (i.e. change their rotation?)

<Border.Style>
    <Style>
        <Style.Triggers>
            <Trigger Property="Border.IsMouseOver" Value="True">
                <Setter Property="Border.Background" Value="#f0f0f0" />
            </Trigger>
        </Style.Triggers>
    </Style>
</Border.Style>

Further down the tree, but inside this border is

<Border Padding="3" Width="73" Height="57" Background="White" RenderTransformOrigin="0.5, 0.5">
    <Border.Effect>
        <DropShadowEffect BlurRadius="4" Direction="0" ShadowDepth="0" Color="#aa505050" />
    </Border.Effect>
    <Border.RenderTransform>
         <RotateTransform Angle="-2" />
    </Border.RenderTransform>
</Border>
5
  • 1
    You could try a DataTrigger in an Inside-Border-Style with FindAncestor or ElementName binding to get Outside-Border-MouseOver.
    – LPL
    May 7, 2013 at 15:37
  • I have no idea how to do that lol, would you mind writing a bit of code for me to look at? Thanks
    – Chris
    May 7, 2013 at 15:50
  • Have you tried ChangePropertyAction with a MouseOver trigger with specified TargetObject's? ;) msdn.microsoft.com/en-us/library/vstudio/dn195723.aspx
    – Chris W.
    May 7, 2013 at 15:59
  • @LPL Managed to get this to work actually, if you want to put it as an answer and Ill accept - thanks
    – Chris
    May 7, 2013 at 16:13
  • Thanks for your offer. I'm not at my desk to share an error free sample. Feel free to add your working code to my answer. ;)
    – LPL
    May 7, 2013 at 16:50

1 Answer 1

2

You could use a DataTrigger in an inner border Style with FindAncestor or ElementName binding to get the IsMouseOver of your outer border.

i.e.

<Border.Style>
    <Style TargetType="Border">
        <Setter Property="RenderTransform">
            <Setter.Value>
                <RotateTransform Angle="3"/>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=IsMouseOver}" Value="True">
                <Setter Property="RenderTransform">
                    <Setter.Value>
                        <RotateTransform Angle="6"/>
                    </Setter.Value>
                </Setter>
            </DataTrigger >
        </Style.Triggers>
    </Style>
</Border.Style>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.