C# 按代码将项目列表绑定到Xbox中

C# 按代码将项目列表绑定到Xbox中,c#,telerik,C#,Telerik,我想在我的应用程序中使用radAutocompletebox。ItemSource是从我的数据库动态获取的。我有这样的代码: var list = extrainfo.database.UserPrivateInfoes; foreach (var item in list) { obs.Add( new RadAutoCompleteBoxItem{Content= item.UName} ); } TX_

我想在我的应用程序中使用radAutocompletebox。
ItemSource
是从我的数据库动态获取的。我有这样的代码:

 var list = extrainfo.database.UserPrivateInfoes;
        foreach (var item in list)
        {
            obs.Add( new RadAutoCompleteBoxItem{Content= item.UName} );
        }
       TX_Receiver.ItemsSource = obs;
obs是可观测的集合

问题是当项目显示在下拉列表中时,我有一个带有两个十字按钮的项目用于删除。其实还不够好!!但是,当我向
ItemSource
添加
String
列表时,问题就解决了。我需要有一个项目,不仅仅是一个字符串的名称,我需要更多的信息(如UID)为每一个项目。 有什么解决办法吗

这是我的新代码:

<DataTemplate x:Key="CustomDropDownItemTemplate">
                <TextBlock 
                            Text="{Binding Content}" />
            </DataTemplate>

ItemsSource="{Binding obs}" DropDownItemTemplate="{StaticResource CustomDropDownItemTemplate}" />

 public class Country
    {
        public string Content;
    }


obs.Add( new Country {Content= item.UName} );
DisplayMemberPath=“内容”

我需要有一个项目,不仅仅是一个字符串的名称,我需要更多的信息(如UID)为每一个项目。有什么解决办法吗

您可以如示例所示完成此操作:

大致如下:

<telerik:RadAutoCompleteBox ItemsSource="{Binding obs}" DropDownItemTemplate="{StaticResource CustomDropDownItemTemplate}"/>

<DataTemplate x:Key="CustomDropDownItemTemplate">
  ... your layout goes here ...
</DataTemplate>

... 你的布局在这里。。。

编辑:还可以查看一下

谢谢。我尝试过这个,但是,当我搜索文本时,它没有显示任何内容。在编辑中查看我的代码。我已经复制并粘贴了示例。我认为名称和资本约束不起作用。它向我显示国家名称以供建议,但当我选择项目时,它会带来一个空项目,但是我的C#代码中的所选项目是正确的,但它不会显示。只有一个带关闭按钮的盒子!!请帮忙!!!
<telerik:RadAutoCompleteBox ItemsSource="{Binding obs}" DropDownItemTemplate="{StaticResource CustomDropDownItemTemplate}"/>

<DataTemplate x:Key="CustomDropDownItemTemplate">
  ... your layout goes here ...
</DataTemplate>