private static void OnItemsSourceChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { CardList control = (CardList)o; IEnumerable value = (IEnumerable)e.NewValue; //先用现有数据更新一次表头,当表头数据加载完成后,用新的表头数据再次更新表头 if (value != null) { control.UpdateItems(); if (value is INotifyCollectionChanged) { ((INotifyCollectionChanged)value).CollectionChanged += (o1, e1) => { control.UpdateItems(); }; } } }
private static void OnItemTemplateChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { CardList control = (CardList)o; control.UpdateItems(); }