Answer the question
In order to leave comments, you need to log in
Why does the List binding on the ListBox not work to the end?
There is such code in the ViewModel:
private List<string> items;
public List<string> Items
{
get
{
items = new List<string> { "1", "2", "3" };
return items;
}
}
<ListBox x:Name="listBox"
Width="612"
Height="475"
Margin="24,179,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
ItemsSource="{Binding Path=Items,
Mode=OneWay}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
private List<string> items;
public List<string> Items
{
get
{
return items;
}
}
items = new List<string>();
items.Add("4");
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question