个人资料

跳过导航链接首页 > 博客列表 > 博客正文

UWP检测鼠标滚轮切换图片

分类:

代码

		public ImagePage()
		{
			this.InitializeComponent();
			this.Loaded += ImagePage_Loaded;
			this.PointerWheelChanged += ImagePage_PointerWheelChanged;
		}

		private void ImagePage_PointerWheelChanged(object sender, PointerRoutedEventArgs e)
		{

			var x = e.GetCurrentPoint(this).Properties.MouseWheelDelta;
			var index = MainPage._ImageObjects.IndexOf(para);
			if (x>0)
			{
				index += 1;
				if (index< MainPage._ImageObjects.Count)
				{
					para = MainPage._ImageObjects[index];
					CurrentImage.Source = para.ImageBrush.ImageSource;
				}

				
			}
			else
			{
				index -= 1;
				if (index >= 0)
				{
					para = MainPage._ImageObjects[index];
					CurrentImage.Source = para.ImageBrush.ImageSource;
				}
			}

			e.Handled = true;
		}

songshizhao
最初发表2019/10/17 0:45:43 最近更新2019/10/17 0:45:43 1107
为此篇作品打分
10
   评论