当XamDataTree运行时添加一个节点到XamDataTree并更新UI
我在我的应用程序中使用了 XamDataTree,我想在 XamDataTree 运行时向树添加一个节点。
加载时
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);
显示 XamDataTree 后 。我想添加一个节点。
Product m_product = new Product();
....to do something on m_product.....
m_DataUtil.AddProduct(m_product);
m_XamDataTree.UpdateLayout();
我不明白为什么树不显示新添加的节点。因为我将它添加到其数据源对象中,并且我认为这应该可行。
有人可以帮助我吗?
提前致谢!
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();
....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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好的解决方案是绑定到具有更改通知的集合(例如 ObservableCollection),这样当您对集合进行更改时,它们将自动反映在 XamDataTree 中。如果您绑定到的集合没有更改通知,那么您应该通过论坛或通过支持案例将问题提交给 Infragistics。以下页面包含两者的链接:
http://www.infragistics.com/support/get-help.aspx
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
在尝试了很多解决方案之后,我找到了该怎么做。看代码;
这有效,希望这个解决方案可以帮助寻找相同功能的人。
After tried many solution I find out what to do. look at the code;
This worked, hope this solution help someone who looking for same functionality.