From 47e10d2323e784ed6a232a3a319b0c0cd782c325 Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Tue, 23 Sep 2025 10:18:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AA=E7=8E=AF=E6=92=AD=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyUserControl/CoverFlowControl.xaml.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml.cs b/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml.cs index c4e437f..d3042d0 100644 --- a/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml.cs +++ b/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml.cs @@ -32,8 +32,16 @@ namespace Wpf_AiSportsMicrospace.MyUserControl get => _selectedIndex; set { - if (value < 0 || value >= Images.Count) return; - _selectedIndex = value; + if (Images.Count == 0) return; + + // 循环处理 + if (value < 0) + _selectedIndex = Images.Count - 1; + else if (value >= Images.Count) + _selectedIndex = 0; + else + _selectedIndex = value; + UpdateLayoutWithAnimation(); } } @@ -87,14 +95,16 @@ namespace Wpf_AiSportsMicrospace.MyUserControl targetScale = centerScale; targetOpacity = 1.0; } - else if (i == SelectedIndex - 1) + else if (i == SelectedIndex - 1 || (SelectedIndex == 0 && i == Images.Count - 1)) { + // 左边图片,循环处理 targetX = centerX - spacing - 75; targetScale = sideScale; targetOpacity = 1.0; } - else if (i == SelectedIndex + 1) + else if (i == SelectedIndex + 1 || (SelectedIndex == Images.Count - 1 && i == 0)) { + // 右边图片,循环处理 targetX = centerX + spacing - 75; targetScale = sideScale; targetOpacity = 1.0;