資源簡(jiǎn)介
這個(gè)類是C# WPF功能的輪播圖,只有一個(gè)類,簡(jiǎn)單。 用的時(shí)候 直接實(shí)例化,然后將需要輪播的List傳進(jìn)去,是參考網(wǎng)上的一個(gè)Demo,但是那個(gè)Demo耗內(nèi)存,我修改了一下
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Threading;
using?System.Windows;
using?System.Windows.Controls;
using?System.Windows.Media;
using?System.Windows.Media.Animation;
using?System.Windows.Media.Imaging;
using?System.Windows.Threading;
namespace?KthSelfDataServiceClient
{
????public?class?ActiveImageAutoScroll?:?UserControl
????{
????????private?static?List?ScrollImages;
????????private?Image?imgAdvertPic?=?new?Image()
????????{
????????????Stretch?=?Stretch.Uniform
????????};
????????public?Grid?MainGrid?=?new?Grid()
????????{
????????????HorizontalAlignment?=?HorizontalAlignment.Stretch
????????????VerticalAlignment?=?VerticalAlignment.Stretch
????????};
????????public?WrapPanel?btnPanel?=?new?WrapPanel();
????????DoubleAnimation?doubleAnimation?=?new?DoubleAnimation();?//創(chuàng)建雙精度動(dòng)畫(huà)對(duì)象
????????public?static?DependencyProperty?advertPicList?=?DependencyProperty.Register(“advertPicList“
????????????typeof(List)?typeof(ActiveImageAutoScroll)
????????????new?Propertymetadata(new?PropertyChangedCallback(ScrollImagesCreateActive)));
????????public?static?DependencyProperty?advertPicStayTime?=?DependencyProperty.Register(“advertPicStayTime“
????????????typeof(List)?typeof(ActiveImageAutoScroll)
????????????new?Propertymetadata(new?PropertyChangedCallback(loadAdvertStayTime)));
????????public?static?DependencyProperty?isShowPageNumBtn?=?DependencyProperty.Register(“isShowPageNumBtn“
????????????typeof(bool)?typeof(ActiveImageAutoScroll)
????????????new?Propertymetadata(new?PropertyChangedCallback(showPageNum)));
????????public?List?AdvertPicStayTime
????????{
????????????get?{?return?(List)GetValue(advertPicStayTime);?}
????????????set?{?SetValue(advertPicStayTime?value);?}
????????}
????????public?List?AdvertPicList
????????{
????????????get?{?return?(List)GetValue(advertPicList);?}
????????????set?{?SetValue(advertPicList?value);?}
????????}
????????public?bool?IsShowPageNumBtn
????????{
????????????get?{?return?(bool)GetValue(isShowPageNumBtn);?}
????????????set?{
????????????????SetValue(isShowPageNumBtn?value);
????????????????if?(!IsShowPageNumBtn)
????????????????{
????????????????????btnPanel.Visibility?=?Visibility.Collapsed;
????????????????}
????????????????else
????????????????{
????????????????????btnPanel.Visibility?=?Visibility.Visible;
????????????????}
????????????}
????????}
????????private?static?void?ScrollImagesCreateActive(Dependencyobject?sender?DependencyPropertyChangedEventArgs?e)
????????{
????????????ActiveImageAutoScroll?advertPicControl?=?(ActiveImageAutoScroll)sender;
????????????if?(e.Property?==?advertPicList)
????????????{
????????????????advertPicControl.AdvertPicList?=?(List)e.NewValue;
????????????????ScrollImages?=?advertPicControl.AdvertPicList;
????????????}
????????}
????????private?static?void?loadAdvertStayTim
評(píng)論
共有 條評(píng)論