您可以用定時器和一個列表框創建自己的幻燈片控制試試這個
你的xaml代碼應該是
<ListBox Grid.Row="1" Name="listControlImage" SelectionChanged="listControlImage_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<Image Height="600" Width="460" Stretch="Fill" Source="{Binding}"/>
</ListBox.ItemTemplate>
</DataTemplate>
後面的代碼你的代碼應該是
//全局變量
List<BitmapImage> ListImages = new List<BitmapImage>();
DispatcherTimer Timer = new DispatcherTimer();
int SlideCount=0;
void Page1_Loaded(object sender, RoutedEventArgs e)
{
LoadImages();
DisTimer.Tick += DisTimer_Tick;
DisTimer.Interval = new TimeSpan(0, 0, 1);
DisTimer.Start();
}
private void LoadImages()
{
ListImages.Add(new BitmapImage(new Uri("/Your project name;component/Image/aaa.jpg", UriKind.Relative)));
ListImages.Add(new BitmapImage(new Uri("/Your project name;component/Image/bbb.jpg", UriKind.Relative)));
ListImages.Add(new BitmapImage(new Uri("/Your project name;component/Image/ccc.jpg", UriKind.Relative)));
ListImages.Add(new BitmapImage(new Uri("/Your project name;component/Image/ddd.jpg", UriKind.Relative)));
ListImages.ItemsSource =ListImages;
}
void DisTimer_Tick(object sender, EventArgs e)
{
if(SlideCount<=3)
{
listControlImage.SelectedIndex = SlideCount;
SlideCount++;
}
else
SlideCount=0;
}
private void listControlImage_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
if(listControlImage.SelectedIndex ==-1)
return;
//Your Navigation code
}
什麼是'Image'? – 2013-12-18 09:31:34
我的照片存儲的路徑。 – bhaskar07
在博客中,我添加了一個計時器控件到我的表單中,但是我的工具箱中沒有任何這樣的控件 – bhaskar07