Stylus.Synchronize Метод

Определение

Синхронизирует курсор и пользовательский интерфейс.

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

Примеры

В следующем примере показано, как получить элемент, который находится под курсором. Вызов Synchronize гарантирует, что DirectlyOver возвращает правильный элемент.

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

Комментарии

Приложениям может потребоваться определить элемент, на котором находится курсор. Если приложение использует анимацию DirectlyOver , метод может вернуть элемент, который был перемещен из-под курсора. Вызовите Synchronize , чтобы убедиться, что DirectlyOver возвращается правильный элемент.

Применяется к