当XamDataTree运行时添加一个节点到XamDataTree并更新UI

发布于 2024-11-19 20:55:33 字数 842 浏览 6 评论 0原文

我在我的应用程序中使用了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

成熟稳重的好男人 2024-11-26 20:55:34

最好的解决方案是绑定到具有更改通知的集合(例如 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

长伴 2024-11-26 20:55:33

在尝试了很多解决方案之后,我找到了该怎么做。看代码;

//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();

这有效,希望这个解决方案可以帮助寻找相同功能的人。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文