You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MAUI中如何让CarouselView响应CurrentItemChanged事件?

MAUI CarouselView CurrentItem绑定与CurrentItemChanged事件失效问题解决

问题场景

使用MAUI的CarouselView控件时,需要实现获取当前选中项并监听其变化的功能,编写的代码如下:

<CarouselView VerticalOptions="Center" PeekAreaInsets="65" Loop="True"
               ItemsSource="{Binding Minutes}" CurrentItem="{Binding SelectedMinute}" CurrentItemChanged="carouselMinutes_CurrentItemChanged">
 <CarouselView.ItemsLayout>

遇到的问题:

  • 默认CurrentItem属性完全无法正常工作
  • 注册CurrentItemChanged事件后,滚动控件时该事件从未触发

解决办法

升级到.NET 8预览版后,上述问题已完全解决,CarouselView控件的CurrentItem绑定和CurrentItemChanged事件均能正常使用。

内容的提问来源于stack exchange,提问作者Toto

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 02:34:50