Stylus.Synchronize Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Synchronizes the cursor and the user interface.
public:
static void Synchronize();
public static void Synchronize ();
static member Synchronize : unit -> unit
Public Shared Sub Synchronize ()
The following example demonstrates how to get the element that is under the cursor. Calling Synchronize ensures that DirectlyOver returns the correct element.
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
Applications may need to determine the element on which the cursor is located. If the application uses animation, the DirectlyOver method might return an element that has moved out from under the cursor. Call Synchronize to be sure that DirectlyOver returns the proper element.
Produkt | Verzie |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
Pripomienky k produktu .NET
.NET je open-source projekt. Ak chcete poskytnúť pripomienky, vyberte prepojenie: