From what I can say for the new bits, you should subscribe to the LLS Link and Unlink . Link is passed to arg, which contains the element added to the visible part of LLS. Unlink does the same for items that are removed from LLS. So you would do something like this:
List<string> trackedItems = new List<string>(); private void myListOfStrings_Link(object sender, LinkUnlinkEventArgs e) { var x = e.ContentPresenter; if (x == null || x.Content == null) return; trackedItems.Add(x.Content.ToString()); } private void myListOfString_Unlink(object sender, LinkUnlinkEventArgs e) { var x = e.ContentPresenter; if (x == null || x.Content == null) return; trackedItems.Remove(x.Content.ToString()); }
Please note that Link and Unlink will be launched for EVERY rendered item in the base list, so if you use the LLS grouping functions, you will have to increase your test of tracking the item based on what type is actually returned. Therefore, if you have some kind of group object for which you want to track the underlying objects, you can do something like this:
private void myGroupedListOfObjects_Link(object sender, LinkUnlinkEventArgs e) { var x = e.ContentPresenter; if (x == null || x.Content == null) return; var myObject = x.Content as MyObject; if (myObject != null) { foreach (var item in myObject.Items) { trackedItems.Add(item); } } }
Hope this helps! Let us know if this works.
source share