views:

369

answers:

1

I have a red border moved by an animation (with a RenderTransform) and the blue border underneath is handling the MouseEnter event.

Unfortunately, the MouseEnter is not fired when the mouse enters the blue border (because the red border has moved away) but when the mouse is moved.

The sample below is tested in Silverlight but I believe the same happens in WPF.

EDIT: after further testing this works in WPF. Is this a bug as MrJul suggests or one of the "missing features" in Silverlight?

XAML

<Grid x:Name="borders" Width="40" Height="20">
    <Grid.Resources>
        <Storyboard x:Key="blueMove">
            <DoubleAnimation Duration="0:0:3" From="0" To="40" Storyboard.TargetName="redBorder"
                         Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.Y)"/>
        </Storyboard>
    </Grid.Resources>
    <Border Background="Blue" MouseEnter="Border_MouseEnter" />
    <Border x:Name="redBorder" Background="Red" MouseLeftButtonDown="Border_MouseLeftButtonDown">
        <Border.RenderTransform>
            <TransformGroup>
                <TranslateTransform Y="0"/>
            </TransformGroup>
        </Border.RenderTransform>
    </Border>
</Grid>

C# code behind

private void Border_MouseEnter(object sender, MouseEventArgs e)
{
 // Only called at the first MouseMove
}

private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
 (borders.Resources["blueMove"] as Storyboard).Begin();
}
A: 

This works fine in WPF but not in Silverlight so one would assume it's a possible bug in Silverlight. I'd suggest you fill an issue report on Connect.

Julien Lebosquain
Thanks MrJul. Before submitting this as a bug I would like to determine if this is not an intentionally missing feature in Silverlight.Also is it possible to have a workaround. I really can't think of a way to trigger the event once and the right time.
Mart
You were right, but they call is an issue, not a bug.
Mart