0
這是自定義對象:如何從組合框綁定對象數據到列表框
public class FileItem
{
public string Name { get; set; }
public string Path { get; set; }
}
Collection
:
public ObservableCollection<FileItem> collection { get; set; }
Combobox
:
<ComboBox
Name="cbCollection"
ItemsSource="{Binding interfaces}"/>
ListBox
:
<ListBox
Name="lbCollection "
ItemsSource="{Binding collection}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
所以我的Combobox
填充了我的object
集合,我想查看我的ListBox
中的所有屬性。
目前:
- 我只能看到屬性
Name
。 - 我可以看到我的
Combobox
中的所有對象,而不僅僅是選定的對象。
,我需要把這個ContentControl中? –
用你的ListBox替換它。 –
錯誤值不能爲空。 參數名稱:dataType和錯誤添加到IDictionary中的所有對象都必須具有Key屬性或與其關聯的其他類型的鍵。 –