StylusDevice.Synchronize Methode

Definition

Synchronisiert den Cursor und die Benutzeroberfläche.

public:
 void Synchronize();
[System.Security.SecurityCritical]
public void Synchronize ();
public void Synchronize ();
[<System.Security.SecurityCritical>]
member this.Synchronize : unit -> unit
member this.Synchronize : unit -> unit
Public Sub Synchronize ()
Attribute

Beispiele

Im folgenden Beispiel wird veranschaulicht, wie ein Element zurückgegeben wird, das sich unter dem Cursor befindet. Beim Aufrufen Synchronize wird sichergestellt, dass DirectlyOver das richtige Element zurückgegeben wird.

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 SynchronizeCurrentStylus()
{
    StylusDevice currentStylus = Stylus.CurrentStylusDevice;

    currentStylus.Synchronize();
    UIElement element = (UIElement) currentStylus.DirectlyOver;
    output.Text += "The stylus is over " + element.ToString() + "\r\n";
}
Sub SynchronizeCurrentStylus()

    Dim currentStylus As StylusDevice = Stylus.CurrentStylusDevice

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

End Sub

Hinweise

Anwendungen müssen möglicherweise das Element suchen, über dem sich der Cursor befindet. Wenn die Anwendung animationen verwendet, gibt die DirectlyOver Methode möglicherweise ein Element zurück, das sich unter dem Cursor entfernt hat. Rufen Sie auf Synchronize , um sicherzustellen, dass DirectlyOver das richtige Element zurückgegeben wird.

Gilt für: