.NET Framework Class Library
ContentElement.IsMouseCaptured Property
Gets a value that indicates whether the mouse is captured by this element.
Assembly: PresentationCore (in PresentationCore.dll)
Syntax
Visual Basic
Public ReadOnly Property IsMouseCaptured As Boolean Get
C#
public bool IsMouseCaptured { get; }
Visual C++
public: virtual property bool IsMouseCaptured { bool get () sealed; }
F#
abstract IsMouseCaptured : bool override IsMouseCaptured : bool
Property Value
Type: System.Booleantrue if the element has mouse capture; otherwise, false. The default is false.
Implements
IInputElement.IsMouseCapturedDependency Property Information
|
Identifier field |
|
|
Metadata properties set to true |
None |
Remarks
Mouse capture state is related to in-process drag-and-drop operations.
Examples
The following example turns the mouse capture state on or off based on whether the mouse is already captured by the element.
Visual Basic
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 Mouse.Capture(target) Else Mouse.Capture(Nothing) End If End If End Sub
C#
private void CaptureMouseCommandExecuted(object sender, ExecutedRoutedEventArgs e) { MessageBox.Show("Mouse Command"); IInputElement target = Mouse.DirectlyOver; target = target as Control; if (target != null) { if (!target.IsMouseCaptured) { Mouse.Capture(target); } else { Mouse.Capture(null); } } }
Version Information
.NET Framework
Supported in: 4, 3.5, 3.0.NET Framework Client Profile
Supported in: 4, 3.5 SP1Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
See Also