1

I want the same thing as in this Question:

Click and hold on button while dragging mouse to make value bigger/smaller

The only answer there was the Slider but that was not what the Question asker meant. And nor what i meant.

I know something like this is possible in iOs, but i want to use it in a windows app, but i cant seem to figure out how to do it.

I tried doing it with pointerpressed, pointerrelease and pointermoved. And it worked in a way but i stops working when you get out of the range from the textblock so it does only work when you drag on the textblock itself, and i want to do it so that you can drag over the whole screen if necessary.

this is what i have so far:

    private void TextBlock_PointerPressed(object sender, PointerRoutedEventArgs e)
    {
        ystart = e.GetCurrentPoint(this).Position.Y;
        clicked = true;
    }

    private void TextBlock_PointerReleased(object sender, PointerRoutedEventArgs e)
    {
        clicked = false;
    }

    private void TextBlock_PointerMoved(object sender, PointerRoutedEventArgs e)
    {
        if(clicked == true)
        {
            yend = e.GetCurrentPoint(this).Position.Y;
            double difference;
            int textgetal = Convert.ToInt32(Block.Text);
            difference = ystart - yend;

            textgetal = textgetal + (Convert.ToInt32(difference) / 10);

            Block.Text = Convert.ToString(textgetal);
        }
    }

and like i said this works, but only inside the range of the textblock and not the whole screen like i want it.

Community
  • 1
  • 1
Verbun
  • 31
  • 8
  • 1
    Have you tried "Capturing" the mouse? see: http://stackoverflow.com/questions/942357/what-does-it-mean-to-capture-the-mouse-in-wpf – Ori Price Jan 05 '15 at 21:03

0 Answers0