Hi All,
I have an issue where I am binding my ViewModel to the TreeView and using a hierarchical data template to allow a self referencing list of items.
I have got this all working fine - however, when I add a new item to the source list, it causes the itemssource on the treeview to be re-evaluated. This in turn calls the converter (which is using a linq query to find the top level of the tree and children).
I think that by calling this converter, the TreeView is losing track of which items were expanded because when the control refreshes, the TreeView is collapsed
This is my converter code (pretty simple):
Any idea if this is easily recitified with an option on the control? If not I assume I will need to track which items are expanded (I was thinking about just putting the IDs in a list and iterating), if so which event is best to use when the underlying itemssource is re-evaluated?
Thanks,
Charles
I have an issue where I am binding my ViewModel to the TreeView and using a hierarchical data template to allow a self referencing list of items.
I have got this all working fine - however, when I add a new item to the source list, it causes the itemssource on the treeview to be re-evaluated. This in turn calls the converter (which is using a linq query to find the top level of the tree and children).
I think that by calling this converter, the TreeView is losing track of which items were expanded because when the control refreshes, the TreeView is collapsed
This is my converter code (pretty simple):
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var item = value as Structure; var items = value as SturctureCollection; if (items != null) { return items.Where(i => i.ParentID == 0); } else if (item != null) { var parent = (item.Parent as StructureCollection); return parent.Where(i => i.ParentID == item.ID); } return null; }Any idea if this is easily recitified with an option on the control? If not I assume I will need to track which items are expanded (I was thinking about just putting the IDs in a list and iterating), if so which event is best to use when the underlying itemssource is re-evaluated?
Thanks,
Charles