0

I am using a scrollviewer having stackpanel with 10 low quality images .When flick once the image moves to the next and load the high resolution image of the viewed image in that view. The problem is when flick 6 times continuously,scroll moves 6 times and the method for add high resolution occurs 6 times and load the image in view. I need an idea to wait for the completed flick for some seconds and execute the high resolution add image method once. Is there any way to do that?

2
  • How are you defining "last flick"? Commented Jul 5, 2012 at 12:03
  • if (e.HorizontalChange < 0) { var helper = DoubleAnimationHelper.Get(scroll, ScrollViewer.HorizontalOffsetProperty); helper.CurrentValue = scroll.HorizontalOffset; helper.TargetValue = y + 480; helper.Duration = TimeSpan.FromMilliseconds(250); scroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; helper.Animate(); x = helper.TargetValue; AddhighresImage() } Commented Jul 5, 2012 at 12:36

1 Answer 1

1

You can delay the loading of the high resolution images using a timer. The code might look something like this:


DispatcherTimer timer = new DispatcherTimer();

public MainPage()
{
    InitializeComponent();

    timer.Interval = TimeSpan.FromSeconds(1); //You can adjust the delay suitable to your needs
    timer.Tick += new EventHandler(timer_Tick);
}

void handle_Flick(object sender, GestureEventArgs args)
{
   //If timer is not running, start the timer 
   //and do everything else other than loading high-resolution image.
   if(timer.IsEnabled != true)
   {
      //start the timer
      timer.Start();
   }
}

void timer_Tick(object sender, EventArgs e)
{
    //Stop the timer
    timer.Stop();

    //Load the high resolution image
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.