ContentElement.IsMouseCaptured ContentElement.IsMouseCaptured ContentElement.IsMouseCaptured ContentElement.IsMouseCaptured Property

Definición

Obtiene un valor que indica si este elemento captura el mouse.Gets a value that indicates whether the mouse is captured by this element.

public:
 property bool IsMouseCaptured { bool get(); };
public bool IsMouseCaptured { get; }
member this.IsMouseCaptured : bool
Public ReadOnly Property IsMouseCaptured As Boolean

Valor de propiedad

true si el elemento tiene la captura del mouse; en caso contrario, false.true if the element has mouse capture; otherwise, false. De manera predeterminada, es false.The default is false.

Implementaciones

Ejemplos

En el siguiente ejemplo se activa o desactiva el estado de la captura del mouse en función de si el elemento ya ha capturado el mouse.The following example turns the mouse capture state on or off based on whether the mouse is already captured by the element.

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);
    }
  }
}
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

Comentarios

El estado de la captura del mouse está relacionado con las operaciones de arrastrar y colocar en proceso.Mouse capture state is related to in-process drag-and-drop operations.

Información sobre propiedades de dependenciaDependency Property Information

Campo de identificadorIdentifier field IsMouseCapturedProperty
Propiedades de metadatos establecidas entrueMetadata properties set to true NingunaNone

Se aplica a

Consulte también: