StylusDevice.Synchronize Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Sincroniza o cursor e a interface do utilizador.
public:
void Synchronize();
[System.Security.SecurityCritical]
public void Synchronize();
[<System.Security.SecurityCritical>]
member this.Synchronize : unit -> unit
Public Sub Synchronize ()
- Atributos
Exemplos
O exemplo seguinte demonstra como devolver um elemento que está sob o cursor. Chamar Synchronize garante que DirectlyOver retorna o elemento correto.
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
Observações
As aplicações podem precisar de localizar o elemento sobre o qual o cursor está posicionado. Se a aplicação usar animação, o DirectlyOver método pode devolver um elemento que saiu debaixo do cursor. Ligue Synchronize para garantir que isso DirectlyOver retorna o elemento correto.