Windows Phone的自动内容滑块

时间:2014-01-07 18:53:40

标签: c# windows-phone-7 telerik windows-phone slideshow

我想知道在Windows Phone(7)应用程序中显示某些文本的最简单方法是什么,每隔几秒就会自动更改一次。是否有一个现成的控件,我可以简单地绑定一个字符串列表,并且还在监听用户输入以手动切换内容?

我考虑过使用Telerik SlideView控件,但我不知道这是否支持自动切换内容。

1 个答案:

答案 0 :(得分:1)

Telerik SlideView control不直接支持幻灯片模式,但添加一个很容易...

(以下代码取自Telerik示例应用程序)

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,显示了这一点。