Dear JS-Support,
I want a controls (Image, TextBlock ...) to achieve a double-click event, how to achieve it?
Thank you.
Regards,
Tomny
Code: Select all
public class TextBlock2 : TextBlock
{
private DateTime _lastPointerPressed = DateTime.Now;
public event PointerEventHandler DoubleClick;
public TextBlock2()
{
this.PointerPressed += MainPage_PointerPressed;
}
void MainPage_PointerPressed(object sender, PointerRoutedEventArgs e)
{
DateTime now = DateTime.Now;
if ((now - _lastPointerPressed).TotalMilliseconds <= 300)
{
if (DoubleClick != null)
{
DoubleClick(this, e);
}
e.Handled = true;
}
_lastPointerPressed = now;
}
}
Code: Select all
<local:TextBlock2 Text="Double-click me to test" DoubleClick="TextBlock2_DoubleClick"/>
Code: Select all
void TextBlock2_DoubleClick(object sender, PointerRoutedEventArgs e)
{
MessageBox.Show("Double-click works!");
}
Users browsing this forum: No registered users and 5 guests