UIElement.ReleaseMouseCapture Yöntem

Tanım

Bu öğe yakalamayı tuttuysa fare yakalamasını serbest bırakır.

C#
public void ReleaseMouseCapture ();

Uygulamalar

Örnekler

Aşağıdaki örnek, için verilen örnekle paraleldir: fare yakalamayı serbest bırakmak ve fareyi hareket ettirmeyi yeniden etkinleştirmek için CaptureMousefare düğmesini yukarı doğru işler.

C#
private void MouseDownHandler(object sender, MouseButtonEventArgs e)
{
    if (!Enabled) return;
    e.Handled = true;

    if (Keyboard.IsKeyDown(Key.F1) == true)
    {
        Reset();
        return;
    }

    UIElement el = (UIElement)sender;
    _point = e.MouseDevice.GetPosition(el);
    // Initialize the center of rotation to the lookatpoint
    if (!_centered)
    {
        ProjectionCamera camera = (ProjectionCamera)_slaves[0].Camera;
        _center = camera.LookDirection;
        _centered = true;
    }

    _scaling = (e.MiddleButton == MouseButtonState.Pressed);

    if (Keyboard.IsKeyDown(Key.Space) == false)
        _rotating = true;
    else
        _rotating = false;

    el.CaptureMouse();
}

private void MouseUpHandler(object sender, MouseButtonEventArgs e)
{
    if (!_enabled) return;
    e.Handled = true;

    // Stuff the current initial + delta into initial so when we next move we
    // start at the right place.
    if (_rotating == true)
    {
        _rotation = _rotationDelta * _rotation;
    }
    else
    {
        _translate += _translateDelta;
        _translateDelta.X = 0;
        _translateDelta.Y = 0;
    }

    //_scale = _scaleDelta*_scale;
    UIElement el = (UIElement)sender;
    el.ReleaseMouseCapture();
}

Açıklamalar

Bu öğe yakalamayı tutmadıysa, bu yöntemi çağırmanın hiçbir etkisi olmaz. Bu yöntemi çağırmadan önce değerini IsMouseCaptured denetlemeyi göz önünde bulundurun.

Şunlara uygulanır

Ürün Sürümler
.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
Windows Desktop 3.0, 3.1, 5, 6, 7

Ayrıca bkz.