[]
Occurs when the pointer device that previously initiated a Press action is released, while within the specific control. Note that the end of a Press action is not guaranteed to fire a PointerReleased event; other events may fire instead. For more info, see Remarks.
public event EventHandler<PointerEventArgs> PointerReleased
Type | Description |
---|---|
EventHandler<PointerEventArgs> | Occurs when the pointer device that previously initiated a Press action is released, while within the specific control. Note that the end of a Press action is not guaranteed to fire a event; other events may fire instead. For more info, see Remarks. |
Note Other events instead of PointerReleased may fire at the end of the action—for example, PointerCanceled or PointerCaptureLost. Don't rely on PointerPressed and PointerReleased events always occurring in pairs. To function properly, your app must listen for and handle all events that represent likely conclusions to the Press action. Some of the reasons why you might not get a PointerReleased occurrence are:
This event is a routed event. If you do not want parent control receive this event, set PointerEventArgs.Handled
The following code example shows how to use this event.
This code example is part of a larger example provided for the PointerPressed event.
public class GcTouchEventProviderPointerDemo : Form
{
private Panel _bluePanel;
private ListBox _messageListBox;
private GcTouchEventProvider _gcTouchEventProvider = new GcTouchEventProvider();
public GcTouchEventProviderPointerDemo()
{
InitializeComponent();
_gcTouchEventProvider.SetEnableTouchEvents(_bluePanel, true);
_gcTouchEventProvider.PointerReleased += _gcTouchEventProvider_PointerReleased;
}
private void _gcTouchEventProvider_PointerReleased(object sender, PointerEventArgs e)
{
string log = "Target: " + e.TargetControl.Name + " Event: PointerReleased" + " X: " + e.Position.X.ToString() + " Y: " + e.Position.Y.ToString();
_messageListBox.Items.Add(log);
}
private void _clearButton_Click(object sender, EventArgs e)
{
_messageListBox.Items.Clear();
}
private void InitializeComponent()
{
_bluePanel = new Panel();
_bluePanel.Name = "Blue";
_bluePanel.BackColor = Color.Blue;
_bluePanel.Size = new Size(200, 200);
_bluePanel.Location = new Point(20, 20);
_messageListBox = new ListBox();
_messageListBox.Size = new Size(750, 310);
_messageListBox.Location = new Point(20, 240);
this.Controls.Add(_bluePanel);
this.Controls.Add(_messageListBox);
}
}
Public Class GcTouchEventProviderPointerDemo
Inherits Form
Private _bluePanel As Panel
Private _messageListBox As ListBox
Private _gcTouchEventProvider As New GcTouchEventProvider()
Public Sub New()
InitializeComponent()
_gcTouchEventProvider.SetEnableTouchEvents(_bluePanel, True)
AddHandler _gcTouchEventProvider.PointerReleased, AddressOf _gcTouchEventProvider_PointerReleased
End Sub
Private Sub _gcTouchEventProvider_PointerReleased(sender As Object, e As PointerEventArgs)
Dim log As String = "Target: " & Convert.ToString(e.TargetControl.Name) & " Event: PointerReleased" & " X: " & e.Position.X.ToString() & " Y: " & e.Position.Y.ToString()
_messageListBox.Items.Add(log)
End Sub
Private Sub InitializeComponent()
_bluePanel = New Panel()
_bluePanel.Name = "Blue"
_bluePanel.BackColor = Color.Blue
_bluePanel.Size = New Size(200, 200)
_bluePanel.Location = New Point(20, 20)
_messageListBox = New ListBox()
_messageListBox.Size = New Size(750, 310)
_messageListBox.Location = New Point(20, 240)
Me.Controls.Add(_bluePanel)
Me.Controls.Add(_messageListBox)
End Sub
End Class