基本信息
源码名称:wpf 图片轮播 实例源码下载(焦点图)
源码大小:0.27M
文件格式:.zip
开发语言:C#
更新时间:2016-12-02
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace WpfPictureChange
{
    /// <summary>
    /// PictureChangeUserControl.xaml 的交互逻辑
    /// </summary>
    public partial class PictureChangeUserControl : UserControl
    {
        public PictureChangeUserControl()
        {
            InitializeComponent();
            IniPic();
        }

        private void IniPic()
        {
            List<PicClass> pic = new List<PicClass>()
            {
                new PicClass(){Image=string.Format(@"/img/diablo.jpg"),Site="1"},
                new PicClass(){Image=string.Format(@"/img/gallardo.jpg"),Site="2"},
                new PicClass(){Image=string.Format(@"/img/Murcielago.jpg"),Site="3"},
                new PicClass(){Image=string.Format(@"/img/Reventon.jpg"),Site="4"},
            };
            this.listBoxPic.ItemsSource = pic;
        }

        DispatcherTimer timer;
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(2000);
            timer.Tick  = new EventHandler(timer_Tick);
            listBoxPic.SelectedIndex = 0;
            timer.Start();

        }

        private void timer_Tick(object sender, EventArgs e)
        {
            if (listBoxPic.Items.Count > 0)
            {

                if (listBoxPic.SelectedIndex == listBoxPic.Items.Count - 1)
                {
                    listBoxPic.SelectedIndex = 0;
                }
                else
                {
                    listBoxPic.SelectedIndex  = 1;
                }
            }
        }

        private void UserControl_Unloaded(object sender, RoutedEventArgs e)
        {
            timer.Stop();
        }
    }
}