Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从WCF服务接收阵列并将其显示在列表框中_C#_Wpf_Wcf - Fatal编程技术网

C# 从WCF服务接收阵列并将其显示在列表框中

C# 从WCF服务接收阵列并将其显示在列表框中,c#,wpf,wcf,C#,Wpf,Wcf,我试图用一个来自wcf服务的对象的条目来创建一个列表框 我基本上是发送一个组请求,然后收到一组与请求匹配的组数组。 然而,我只是设法显示了对象的名称,而不是它的内容 有什么想法吗?我可能错过了显而易见的东西,但却无法真正发现它 int i = 1; GroupServiceClient client = new GroupServiceClient("WSHttpBinding_IGroupService"); www.test.co.uk.Use

我试图用一个来自wcf服务的对象的条目来创建一个列表框 我基本上是发送一个组请求,然后收到一组与请求匹配的组数组。 然而,我只是设法显示了对象的名称,而不是它的内容

有什么想法吗?我可能错过了显而易见的东西,但却无法真正发现它

        int i = 1;
        GroupServiceClient client = new GroupServiceClient("WSHttpBinding_IGroupService");
        www.test.co.uk.User.user User = new www.test.co.uk.User.user();
        www.test.co.uk.programme.programme Group = new www.test.co.uk.programme.programme();
        www.test.co.uk.programme.programme[] Groups = new www.test.co.uk.programme.programme[i];

        DateTime time = DateTime.Now;
        values.Clear();
        client.Open();

        Group.number = Convert.ToString(textBox1.Text);
        client.GetGroups(ref time, Group);


        GroupArrayMessage toReturn = new GroupArrayMessage();
        toReturn.groups = Groups;


        listBox1.ItemsSource = Groups.ToString(); ;
首先 无法使用Group.ToString(),因为任何ItemControl的ItemSource属性都只接受列表类型的对象

所以 使用


谢谢,但是我在列表框1中没有函数DisplayMember再次感谢仍然没有任何内容,如果我将返回字符串,它将返回www.test.co.uk.program.program[]每行一个字符。您能描述一下“没有”吗?也许您需要一个ToList(),但肯定不是ToString(),列表框仍然为空,而如果我尝试使用wcftestclient,我会得到组列表,因此我知道后端很好。请使用调试器和/或输出窗口。
listBox1.ItemsSource = Groups;       // no .ToString()
listBox1.DisplayMemberPath = "Name"; // should be a Group property
listBox1.ItemSource = Groups;