StylusDevice.Synchronize Metodo

Definizione

Sincronizza il cursore e l'interfaccia utente.

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 ()
Attributi

Esempio

Nell'esempio seguente viene illustrato come restituire un elemento che si trova sotto il cursore. La chiamata Synchronize garantisce che DirectlyOver restituisca l'elemento corretto.

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

Commenti

Le applicazioni potrebbero dover individuare l'elemento posizionato sul cursore. Se l'applicazione usa l'animazione, il DirectlyOver metodo potrebbe restituire un elemento che è stato spostato da sotto il cursore. Chiamare Synchronize per assicurarsi che DirectlyOver restituisca l'elemento appropriato.

Si applica a