StylusDevice.Synchronize 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
同步處理游標和使用者介面。
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 ()
- 屬性
範例
下列範例示範如何傳回游標底下的專案。 呼叫 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 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
備註
應用程式可能需要找出游標所在的專案。 如果應用程式使用動畫,方法 DirectlyOver 可能會傳回已從游標下方移出的專案。 呼叫 Synchronize 以確定 DirectlyOver 會傳回適當的專案。