public MainPage() { sitecoreServiceClient = new SitecoreServiceClient(); sitecoreServiceClient.GetFixedPathsCompleted += (sender, e) => { e.Result.Content_Comments.Children.LoadChildren((commentChildren) => { allComments = commentChildren.LoadedChildren.OfType<Comment>(); FeedCollection = e.Result.Content_Feeds; FeedCollection.Children.LoadChildren((feedCollectionChildren) => { foreach (Feed feed in feedCollectionChildren.LoadedChildren.OfType<Feed>()) { feed.Children.LoadChildren((feedChildren) => { foreach (FeedItem feedItem in feedChildren.LoadedChildren.OfType<FeedItem>()) { feedItem.Comments = new ObservableCollection<Comment>(from comment in allComments where comment.FeedItem != null && comment.FeedItem.ReferenceId == feedItem.ItemID select comment); } }); } if (!initialized) { InitializeComponent(); initialized = true; } }); }); }; sitecoreServiceClient.GetFixedPathsAsync(); }
public void LoadChildren(Action<ChildItemCollectionRef> callback) { SitecoreServiceClient client = new SitecoreServiceClient(); client.GetChildrenCompleted += (sender, e) => { LoadedChildren = e.Result != null ? new ObservableCollection<Item>(e.Result) : new ObservableCollection<Item>(); if (callback != null) { callback(this); } }; client.GetChildrenAsync(ParentId); }