0

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();
}
Mart
  • 5,608
  • 3
  • 32
  • 45
  • I just submitted this as a bug on connect.microsoft.com, but I'm still looking for a workaround. – Mart Oct 03 '09 at 08:58
  • Microsoft Connect sent the following comment: "We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution." which doesn't mean this has been accepted as a bug. – Mart Oct 07 '09 at 11:30
  • Microsoft Connect finally sent a disappointing answer: this is a known issue (but not a bug). Indeed as stated on MouseEnter event page (http://msdn.microsoft.com/en-us/library/system.windows.uielement.mouseenter%28VS.95%29.aspx): "MouseEnter is not raised if the mouse pointer (or the stylus tip) remains stationary, and an object with a MouseEnter handler has its position animated or otherwise adjusted to move under the mouse pointer" That means no solution for that problem. – Mart Feb 01 '10 at 12:54

1 Answers1

0

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
  • 40,639
  • 8
  • 105
  • 117
  • 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 Oct 03 '09 at 07:15