Condividi tramite


Thumb.DragDelta Evento

Definizione

Si verifica una o più volte quando il mouse cambia posizione quando un Thumb controllo ha lo stato attivo logico e l'acquisizione del mouse.

public:
 event System::Windows::Controls::Primitives::DragDeltaEventHandler ^ DragDelta;
public event System.Windows.Controls.Primitives.DragDeltaEventHandler DragDelta;
member this.DragDelta : System.Windows.Controls.Primitives.DragDeltaEventHandler 
Public Custom Event DragDelta As DragDeltaEventHandler 

Tipo evento

Esempio

Nell'esempio seguente viene illustrato come assegnare un gestore eventi per l'evento DragDelta a un Thumb controllo e come definire il gestore eventi. Per l'esempio completo, vedere Thumb Drag Functionality Sample (Esempio di funzionalità di trascinamento del cursore).

<Thumb Name="myThumb" Canvas.Left="80" Canvas.Top="80" Background="Blue" 
      Width="20" Height="20" DragDelta="onDragDelta" 
      DragStarted="onDragStarted" DragCompleted="onDragCompleted"
      />
void onDragDelta(object sender, DragDeltaEventArgs e)
{
    //Move the Thumb to the mouse position during the drag operation
    double yadjust = myCanvasStretch.Height + e.VerticalChange;
    double xadjust = myCanvasStretch.Width + e.HorizontalChange;
    if ((xadjust >= 0) && (yadjust >= 0))
    {
        myCanvasStretch.Width = xadjust;
        myCanvasStretch.Height = yadjust;
        Canvas.SetLeft(myThumb, Canvas.GetLeft(myThumb) +
                                e.HorizontalChange);
        Canvas.SetTop(myThumb, Canvas.GetTop(myThumb) +
                                e.VerticalChange);
        changes.Text = "Size: " +
                        myCanvasStretch.Width.ToString() +
                         ", " +
                        myCanvasStretch.Height.ToString();
    }
}

Commenti

Il Thumb controllo riceve lo stato attivo e l'acquisizione del mouse quando l'utente preme il pulsante sinistro del mouse mentre sospendo il puntatore del mouse sul Thumb controllo. Il Thumb controllo perde l'acquisizione del mouse quando l'utente rilascia il pulsante sinistro del mouse o quando viene chiamato il CancelDrag metodo .

Si verifica un nuovo DragDelta evento ogni volta che la posizione del mouse si sposta sullo schermo. Pertanto, questo evento può essere generato più volte senza un limite quando un controllo ha l'acquisizione Thumb del mouse.

Informazioni sugli eventi indirizzati

Item Valore
Campo Identificatore DragDeltaEvent
Strategia di routing Bubbling
Delegato DragDeltaEventHandler

Si applica a

Vedi anche