xamarin.forms - 为 CarouselViewControl 实现 SelectedItem
问题描述
为 CarouselViewControl 实现 SelectedItem(如在 ListView 上)
尝试过 PositionSelected 和 PositionSelectedCommand 不起作用,因为它给出了列表中所选项目的位置。
视图模型实现:
private void LoadData(IEnumerable<Model> myCourse)
{
this.Items.Clear();
if (myCourse != null)
{
foreach (var item in myCourse)
{
var itemToAdd = new Model
{
ActiviyId = item.ActiviyId,
};
Device.BeginInvokeOnMainThread(() =>
{
this.Items.Add(itemToAdd);
});
}
}
}
public DelegateCommand<Model> CourseSelectedCommand => new DelegateCommand<Model>(async (Param) => await this.OnCourseItemSelectedCommand(Param));
private async Task OnCourseItemSelectedCommand(Model model)
{
var navigationParams = new NavigationParameters();
navigationParams.Add("ActivityID", model.ActiviyId);
await this.navigationService.NavigateAsync("ModulePage", navigationParams, true, false);
}
解决方案
推荐阅读
- visual-c++ - Win32_Processor.ProcessorId 的格式是什么?
- google-chrome - 如何使用 Chrome 扩展程序获取页面加载时间?
- scikit-learn - sklearn SVC 在执行时抛出“重塑错误”
- python - 制图。在 Python 中使用地图上的色标来可视化移动速度
- javascript - WebGL 2.0 问题 - 我如何旋转和翻译?
- android - iOS 和 Android 之间的 React Native 不同渲染
- reactjs - react componentDidMount中未定义递归异步函数
- html - 在 Heroku 上部署时图像未加载
- laravel-nova - 如何在帖子的创建页面中使用用户的属性作为默认值?
- javascript - 访问 ejs 文件中脚本标签中传递的元素