0
我試圖定義ListBox來顯示我在某個集合中定義的所有元素。看不到我列表框中的項目
代碼:
public class Element
{
private string _name;
public string Name { get { return _name; } }
public Element(string name)
{
_name = name;
}
}
public class ElementCollection
{
public List<Element> Elements
{
get;
set;
}
}
<ListBox ItemsSource="{Binding ElementCollection}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Element.Name}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
我做 '的DataContext',所有的數據都在正確的地方。
我做錯了什麼?
嘗試..不工作 – Yanshof
現在看看,剛剛發現另一件事是WASN」 t right – Horia
still still work :( – Yanshof