The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Stylus.Synchronize Method

Synchronizes the cursor and the user interface.

Namespace: System.Windows.Input
Assembly: PresentationCore (in presentationcore.dll)

public static void Synchronize ()
public static void Synchronize ()
public static function Synchronize ()
You cannot use methods in XAML.

Applications may need to determine the element on which the cursor is located. If the application uses animation, the DirectlyOver method might return an element that has moved out from under the cursor. Call Synchronize to be sure that DirectlyOver returns the proper element.

The following example demonstrates how to get the element that is under the cursor. Calling Synchronize ensures that DirectlyOver returns the correct element.

    void AnimateButton()
        TranslateTransform buttonTransform = new TranslateTransform(0, 0);
        button1.RenderTransform = buttonTransform;

        // Animate the Button's position.
        DoubleAnimation myDoubleAnimation = new DoubleAnimation();
        myDoubleAnimation.From = 0;
        myDoubleAnimation.By = 100;
        myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(5));
        myDoubleAnimation.AutoReverse = true;
        myDoubleAnimation.RepeatBehavior = RepeatBehavior.Forever;

        buttonTransform.BeginAnimation(TranslateTransform.XProperty, myDoubleAnimation);       


    void SynchronizeStylus()
        UIElement element = (UIElement)Stylus.DirectlyOver;
        output.Text += "The stylus is over " + element.ToString() + "\r\n";

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft