我有下面的代碼WPF,的ObservableCollection和列表框
private static ObservableCollection<myColor> myItems = new ObservableCollection<myColor>();
myItems.Add(new myColor("red"));
當對象myColor是該類
public class myColor
{
public string color { get; set; }
public myColor(string col)
{
this.color = col;
}
}
麻煩的是,當我嘗試在列表框中顯示的項目
<ListBox Margin="12,52,12,12" Name="listBox1" ItemsSource="{Binding}" />
它只顯示「myColor」對象而不是「顏色」變量。我怎樣才能顯示這個對象的變量?