使用WCF服务绑定Treeview [英] Binding Treeview using WCF Services

查看:55
本文介绍了使用WCF服务绑定Treeview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在customer中有2个表customer和user cust_no对于该Customer是唯一的,我可以为该特定Customer添加任意数量的用户.应该是子节点(例如,如果我们有10个客户,而每个客户有1个以上的用户,则单击客户编号",我们必须将用户编号作为子节点)

我尝试了一点Cust No,但无法获得用户No作为子节点

Hi,

I have 2 tables customer and user in customer cust_no is unique for that Customer i can add any number of users for that particular Customer No So, Now i have to show this in a TreeView like Customer No should be the Parent Node and the User No should be the Child Node (Like if we have 10 Customers and each Customer have more than 1 User if we click on Cust No we have to get the User No as Child Nodes)

I have tried a bit i got the Cust No but not able to get the User No as the Child Nodes

void FillTreeView()
        {
            client.CustNoCompleted += new System.EventHandler<CustNoCompletedEventArgs>(client_CustNoCompleted);
            client.CustNoAsync();

        }

        void client_CustNoCompleted(object sender, CustNoCompletedEventArgs e)
        {
            TreeViewItem tvitem = new TreeViewItem();
            tvitem.Header = "Customer";

            List<Cust> cust = e.Result;
            var list = from o in cust
                       select o.Customer_No;

            custtreeview.ItemsSource = list;

            //treeview.ItemsSource = list;

        }

推荐答案

您已阅读本文吗?

如何:使用TreeView显示分层数据 [ ^ ]
Have you read this article?

How to: Use a TreeView to Display Hierarchical Data[^]


您需要使用绑定,如下所示.

You need to use binding as demonstrated below.

<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" Margin="5,0" />
</StackPanel>
</control:HierarchicalDataTemplate>
</control:TreeView.ItemTemplate>



另外,请参见此处 [



Also, see here[^].


这篇关于使用WCF服务绑定Treeview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆