this is my code:
<Window x:Class="WpfApplication1.Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window2" Height="300" Width="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="60*" />
<RowDefinition Height="202*" />
</Grid.RowDefinitions>
<Button Click="Button_Click">Click Me</Button>
<ListView ItemsSource="{Binding Numbers}" Grid.Row="1">
</ListView>
</Grid>
public partial class Window2 : Window {
public int index =0;
public ObservableCollection<int> Numbers { get; set; }
public Window2() {
Numbers = new ObservableCollection<int>() { index, index, index, index };
InitializeComponent();
DataContext = this;
}
private void Button_Click(object sender, RoutedEventArgs e) {
Numbers = new ObservableCollection<int>() { index, index, index, index };
index++;
}
}