【发布时间】:2015-07-27 16:50:01
【问题描述】:
我有一个带有结构的自定义列表 类别 -ID -姓名 -颜色 我创建了一个列表并将其绑定到我的 xaml 页面中的组合框名称 categoryListBox。
我尝试过使用这段代码
List<category> categoryCollection = await categoryList.GetCategoryListAsync();
categoryListBox.ItemsSource = categoryCollection;
categoryListBox.DisplayMemberPath = "name";
categoryListBox.SelectedValuePath = "id";
每当我运行应用程序时,我得到的只是一个空白屏幕,尽管当我使用收集项目时
var item = categoryListBox.Items;
它显示它的类型 System.Generic.Lists 具有它应该具有的项目数。我似乎在这里停滞不前,不知道有什么问题。我什至看了example,但看不懂。
这是组合框的定义
<ComboBox
Canvas.ZIndex="100"
Name="categoryListBox"
Foreground="Black"
Margin="10,0"
PlaceholderText="Select.."
Style="{StaticResource ComboBoxStyle1}"/>
【问题讨论】:
标签: c# xaml data-binding combobox windows-phone-8.1