ContentElement.ReleaseMouseCapture ContentElement.ReleaseMouseCapture ContentElement.ReleaseMouseCapture ContentElement.ReleaseMouseCapture Method

Définition

Libère la capture de la souris si cet élément suspend la capture.Releases the mouse capture, if this element held the capture.

public:
 virtual void ReleaseMouseCapture();
public void ReleaseMouseCapture ();
abstract member ReleaseMouseCapture : unit -> unit
override this.ReleaseMouseCapture : unit -> unit
Public Sub ReleaseMouseCapture ()

Implémente

Exemples

Le gestionnaire suivant capture ou libère la capture de la souris en fonction des États de bouton de la souris.The following handler captures or releases mouse capture according to mouse button states. L’exemple montre comment utiliser le déplacement de souris capturé à d’autres fins que de déplacer le pointeur de la souris le Interface utilisateurUI.The example shows how to use captured mouse movement for alternative purposes other than moving the mouse pointer in the Interface utilisateurUI.

private void MouseDownHandler(object sender, MouseButtonEventArgs e)
{
    ContentElement el = (ContentElement)sender;
    if (!el.IsEnabled) return;
    e.Handled = true;
    el.CaptureMouse();
    _point = e.MouseDevice.GetPosition(el); 
}

private void MouseUpHandler(object sender, MouseButtonEventArgs e)
{
    ContentElement el = (ContentElement)sender;
    if (!el.IsEnabled) return;
    e.Handled = true;
    el.ReleaseMouseCapture();
}
Private Sub MouseDownHandler(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
	Dim el As ContentElement = CType(sender, ContentElement)
	If Not el.IsEnabled Then
		Return
	End If
	e.Handled = True
	el.CaptureMouse()
	_point = e.MouseDevice.GetPosition(el)
End Sub

Private Sub MouseUpHandler(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
	Dim el As ContentElement = CType(sender, ContentElement)
	If Not el.IsEnabled Then
		Return
	End If
	e.Handled = True
	el.ReleaseMouseCapture()
End Sub

Remarques

Si cet élément ne contenait pas la capture, l’appel de cette méthode n’a aucun effet.If this element did not hold the capture, calling this method has no effect. Envisagez de vérifier la valeur de IsMouseCaptured avant d’appeler cette méthode.Consider checking the value of IsMouseCaptured before you call this method.

S’applique à

Voir aussi