Thomas
Thomas

Reputation: 4297

Automatic content slider for Windows Phone

I'm wondering what would be the easiest way to display some text inside a Windows Phone (7) app that autimatically changes every few seconds. Is there a ready-to-use control out there that I can simply bind a list of strings to and that is also listening to user input for manually switching content?

I thought about using the Telerik SlideView control, however I can't tell if this supports automatically switching content.

Upvotes: 0

Views: 263

Answers (1)

Neil Turner
Neil Turner

Reputation: 2727

The Telerik SlideView control doesn't directly support a slideshow mode but it's very easy to add one...

(the following code is taken from the Telerik Examples app)

private DispatcherTimer playTimer;

public FirstLook()
{
    this.playTimer = new DispatcherTimer();
    this.playTimer.Interval = TimeSpan.FromSeconds(2);
    this.playTimer.Tick += this.OnPlayTimerTick;
}

private void OnPlayTimerTick(object sender, EventArgs e)
{
    this.slideView.MoveToNextItem();
}

private void OnPlayTap(object sender, GestureEventArgs e)
{
    if (this.playTimer.IsEnabled)
    {
        this.StopSlideShow();
    }
    else
    {
        this.playTimer.Start();
        this.buttonImage.Source = new BitmapImage(new Uri("Images/pause.png", UriKind.RelativeOrAbsolute));
    }
}

private void StopSlideShow()
{
    this.playTimer.Stop();
    this.buttonImage.Source = new BitmapImage(new Uri("Images/play.png", UriKind.RelativeOrAbsolute));
}

The demo app is available on the Windows Phone Store, which shows this in motion.

Upvotes: 1

Related Questions