微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

CollectionView 不显示元素,直到我在调试模式下使用 xamarin 棱镜重新保存 xaml 页面

如何解决CollectionView 不显示元素,直到我在调试模式下使用 xamarin 棱镜重新保存 xaml 页面

第一次面对这个,不知道是不是来自prism,但是好像collection view不接受第一次的数据。

Initial debug mode

After re-save xaml file during debug

Xmal 代码一个普通的集合视图

查看型号代码

public class FacilitiesViewviewmodel : viewmodelBase,INavigationAware
    {
        other variables deFinitions

        private readonly INavigationService _navigationService;
        public ObservableCollection<Court> CourtsItemsBySport { get; set; }

        public FacilitiesViewviewmodel(INavigationService navigationService) :
            base(navigationService)
        {
            _navigationService = navigationService;
            CourtsItemsBySport = new ObservableCollection<Court>();

        }

        private async void GetCourtItems(int sportID)
        {
            var data = await new CourtDataService().GetCourtsItemsBySportAsync(sportID);
            CourtsItemsBySport.Clear();

            foreach (var item in data)
            {
                CourtsItemsBySport.Add(item);
            }
            TotalCourtItems = CourtsItemsBySport.Count(); /* this variable is shown during initial debug,and CourtsItemsBySport is having values but not shown in collectionview */
        }
// this function is getting the passed parameter from another view model

#pragma warning disable CS0114 // Member hides inherited member; missing override keyword

        public void OnNavigatedTo(INavigationParameters parameters)

#pragma warning restore CS0114 // Member hides inherited member; missing override keyword

        {
            SelectedSport = parameters.GetValue<Sport>("SelectedSport");
            CourtsItemsBySport = new ObservableCollection<Court>();
            GetCourtItems(SelectedSport.SportID);

        }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。