Binding ObservableCollection to DataGrid

Jan 2, 2010 at 7:17 PM
Edited Jan 4, 2010 at 5:04 PM
Hello,
I have next:
<StackPanel>
        <Button Click="Button_Click" Content="Press me!"/>
        <dg:DataGrid Name="dataGrid"/>
</StackPanel>
public partial class Window1 : Window
{
        ObservableCollection<My> list = new ObservableCollection<My>();

        public Window1()
        {
            InitializeComponent();
            dataGrid.ItemsSource = list;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            list.Add(new My());
        }
}

class My
{
        public string a { get; set; }
        public string b { get; set; }
        public My() { a = "1"; b = "2"; }
}
It works, but I don't see free white row (and can't add new row) when program starts.
Only if I press button, new row added and I can to add new rows.
How can I add new items both by button and in Datagrid?