Stylus.Synchronize Método

Definición

Sincroniza el cursor y la interfaz de usuario.

public:
 static void Synchronize();
public static void Synchronize ();
static member Synchronize : unit -> unit
Public Shared Sub Synchronize ()

Ejemplos

En el ejemplo siguiente se muestra cómo obtener el elemento que está bajo el cursor. La llamada a Synchronize garantiza que DirectlyOver devuelve el elemento correcto.

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);       
}
Sub AnimateButton() 
    Dim buttonTransform As New TranslateTransform(0, 0)
    button1.RenderTransform = buttonTransform
    
    ' Animate the Button's position.
    Dim myDoubleAnimation As 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)

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

    Stylus.Synchronize()
    Dim element As UIElement = CType(Stylus.DirectlyOver, UIElement)
    output.Text += "The stylus is over " + element.ToString() & vbCr & vbLf

End Sub

Comentarios

Es posible que las aplicaciones necesiten determinar el elemento en el que se encuentra el cursor. Si la aplicación usa animación, el DirectlyOver método podría devolver un elemento que se ha movido debajo del cursor. Llame Synchronize a para asegurarse de que DirectlyOver devuelve el elemento adecuado.

Se aplica a