如何在visual studio 2013中制作Windows Phone 8应用的幻灯片?

时间:2014-10-22 20:51:44

标签: c# visual-studio windows-phone-8

我是Windows Phone Dev的新手。我想在C#中使用滑动手势为图像做幻灯片,但我不能......开发应用程序适用于Visual Studio 2013中的Win8。

有人知道一个很好的教程或一些例子吗? 干杯!

1 个答案:

答案 0 :(得分:1)

我认为您正在寻找的控件是 FlipView

它适用于Windows 8.1和Windows Phone 8.1

使用它很简单,在XAML中添加:

// SelectionChanged event will be fired every time a picture changes (optional)
<FlipView x:Name="flipView1" SelectionChanged="FlipView_SelectionChanged">
    // Of course replace the source with the relative paths 
    // of the pictures you want to show
    <Image Source="Assets/Logo.png" />
    <Image Source="Assets/SplashScreen.png" />
    <Image Source="Assets/SmallLogo.png" />
</FlipView>

这是FlipView控件的简单用法,但是一如既往最好使用Bindings和MVVM设计模式,以防你在这里使用它是你应该写的

在您的XAML中:

<FlipView x:Name="Diaporama"
          ItemsSource="{Binding FlipViewImage}">
     <FlipView.ItemTemplate>
          <DataTemplate>
              <Image Source="{Binding}"
                     Stretch="Fill" />
          </DataTemplate>
     </FlipView.ItemTemplate>
</FlipView>

在我的ViewModel中:

// I binded the FlipView with FlipViewImage
// which is a list of strings (each string being a path)
private List<string> _flipViewImage;

public List<string> FlipViewImage
{
   get { return _flipViewImage; }
   set
   {
      _flipViewImage = value;
      NotifyPropertyChanged("FlipViewImage");
   }
}

// Then I fill the list
FlipViewImage = new List<string>
{
   // Again replace the image paths with your own
   "../Assets/Seel_photo_Aurelien.png",
   "../Assets/shop_woman.jpg",
   "../Assets/Poster.jpg"
};

您现在可以使用滑动手势更改图片幻灯片。

我刚刚展示了你可以用它做的基本知识,你可以在MSDN网站上找到更多或者在Google上找到

Msdn documentation for FlipView