I used XamDataTree in my app and I want to add a node to tree when the XamDataTree is running.
when loading
m_XamDataTree.ItemsSource = m_DataUtil.Data;
NodeLayout mylayout = new NodeLayout();
mylayout.Key = "FristLayout";
mylayout.TargetTypeName = "Category";
mylayout.DisplayMemberPath = "CategoryName";
NodeLayout mylayout2 = new NodeLayout();
mylayout2.Key = "SecondLayout";
mylayout2.TargetTypeName = "Product";
mylayout2.DisplayMemberPath = "FileName";
m_XamDataTree.GlobalNodeLayouts.Add(mylayout);
m_XamDataTree.GlobalNodeLayouts.Add(mylayout2);
after dispalying XamDataTree. I want to do add a node.
Product m_product = new Product(); 开发者_如何学C
....to do something on m_product.....
m_DataUtil.AddProduct(m_product);
m_XamDataTree.UpdateLayout();
I don't understand why the tree don't show the new added node. since I add it to its data source object and I think this should work.
could any one help me ?
thanks in advance!
After tried many solution I find out what to do. look at the code;
//set the data provider null
m_DataUtil = null;
//reload data to data provider class
this.InitData();
//set xamdatatree data source
m_XamDataTree.ItemsSource = m_DataUtil.Data;
//then call this function
m_XamDataTree.UpdateLayout();
This worked, hope this solution help someone who looking for same functionality.
The best solution would be to bind to a collection that has change notifications such as an ObservableCollection so that when you make changes to the collection they will be reflected in the XamDataTree automatically. If you are binding to a collection that doesn't have change notifications then you should submit the issue to Infragistics either on the forums or through a support case. The following page has links for both: http://www.infragistics.com/support/get-help.aspx
精彩评论