ContentElement.IsMouseCaptured Property


Gets a value that indicates whether the mouse is captured by this element.

Namespace:   System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)

Public ReadOnly Property IsMouseCaptured As Boolean

Property Value

Type: System.Boolean

true if the element has mouse capture; otherwise, false. The default is false.

Mouse capture state is related to in-process drag-and-drop operations.

Identifier field


Metadata properties set to true


The following example turns the mouse capture state on or off based on whether the mouse is already captured by the element.

Private Sub CaptureMouseCommandExecuted(ByVal sender As Object, ByVal e As ExecutedRoutedEventArgs)
  MessageBox.Show("Mouse Command")
  Dim target As IInputElement = Mouse.DirectlyOver

  target = TryCast(target, Control)
  If target IsNot Nothing Then
	If Not target.IsMouseCaptured Then
	End If
  End If
End Sub

.NET Framework
Available since 3.0
Return to top