/// <summary> /// track every item in the host's list (these are data items) /// Generate an appropriate depth for them /// </summary> /// <param name="host"></param> private void UpdateItemsTracker(TwitterPanel host) { trackedItems = (from trackers in trackedItems where host.Items.Contains(trackers.Item) select trackers).ToList(); var newtrackers = from item in host.Items where trackedItems.Any(t => t.Item.Equals(item)) == false select MakeTracker(item, null); trackedItems.AddRange(newtrackers); // order trackedItems to be the right order according to the host trackedItems = (from item in host.Items select trackedItems.First(t => t.Item.Equals(item))).ToList(); // Adjust the depths for all the trackers, to account for new items int depth = -300; foreach (var track in trackedItems) { track.Z = depth; depth -= 1000; } // join every item in the hosts data list with all our known tracked items // this is a left join so we preserve existing tracker items //var newlist = (from child in host.Items // join known in trackedItems on child equals known.Item into joined // from item in joined.DefaultIfEmpty() // select MakeTracker(child, item)).ToList(); //int cnt = host.Items.Count; //var x = (from child in host.Items // join known in trackedItems on child equals known.Item into joined // from item in joined.DefaultIfEmpty() // where item == null // select child).ToList(); //// Adjust the depths for all the trackers, to account for new items //int depth = -300; //foreach (var track in newlist) //{ // track.Z = depth; // depth -= 1000; //} //trackedItems = newlist; }
void New3DPanel_Loaded(object sender, RoutedEventArgs e) { Host = ItemsControl.GetItemsOwner(this) as TwitterPanel; Host.SelectionChanged += new SelectionChangedEventHandler(Host_SelectionChanged); }