I have a problem with my silverlight treeview which is bound to an observable collection. The treeview binding is working perfectly across all operations apart from when I try to edit an existing item in the treeview, in which I popup a new child window and pass the treemanager object to it. Treemanager is essentially a custom class maintaining my observable collection. The code updates the underlying item in the observable collection as if it seems to have a pointer to the treemanager object, but it doesnt update the treeview, even if i specifically tell it to rebind to the obervable collection.
Code for right click:
TreeViewItem treeItem = this.RCM.GetClickedElement<TreeViewItem>();// as TreeViewItem;
TreeManager treeManager = ((TreeManager)(((HeaderedItemsControl)(treeItem)).Header));
if (treeManager.Type != "diObject")
{
Message.ErrorMessage("Please select the root DiObject to edit");
return;
}
EditWindow editdlg = new EditWindow(DiObjectNameToList(treeManager), driverComboItems, deviceIntTypeComboItems);
editdlg.Title = "Edit DIObject - "+treeManager.Title;
editdlg.Closed += new EventHandler(editdlg_Closed);
editdlg.t_orig = treeManager;
editdlg.t = treeManager;
editdlg.Show();
Child view window:
public partial class EditWindow : ChildWindow
{
Dictionary<string, string> diObject;
String[] driverComboItems;
String[] deviceIntTypeComboItems;
public TreeManager t { get; set; }
public TreeManager t_orig { get; set; }
public EditWindow(Dictionary<string, string> _diObject, String[] _driverComboItems, String[] _deviceIntTypeComboItems)
{..}
}
treeManager class:
public class TreeManager
{
public TreeManager() { }
public TreeManager(string title)
{
Title = title;
}
public string Title { get; set; }
public ObservableCollection<TreeManager> childElementsValue = new ObservableCollection<TreeManager>();
public ObservableCollection<TreeManager> ChildElements
{
get { return childElementsValue; }
set { childElementsValue = value; }
}
}
The TreeManager class does not implement the INotifyPropertyChanged interface. So changes in the Title do not get propagated to the bindings and user interface.