0
我正在使用下面的代碼來顯示組合框中的項目。但項目沒有得到顯示。Combobox和它的項目顯示問題wpf
代碼:
<ComboBox Width="100" ItemsSource="{Binding}" SelectedIndex="0" Name="cbProduct"/>
List<ComboObject> combObjList = new List<ComboObject>();
combObjList.Add(new ComboObject { Text = "All", Value = "%" });
combObjList.Add(new ComboObject { Text = "Music", Value = "1" });
combObjList.Add(new ComboObject { Text = "Games", Value = "2" });
combObjList.Add(new ComboObject { Text = "Video", Value = "3" });
cbProduct.DataContext= combObjList;
cbProduct.DisplayMemberPath = "Text";
cbProduct.SelectedValuePath = "Value";
它對我來說工作正常 - 但你的代碼隱藏代碼寫在哪裏 - 在事件處理程序中? – Goblin 2010-07-15 15:19:53