I am using WPF application in this form have one gridview and one button
i am using the ObservableCollection have Generic and one class code like this
public partial class MainWindow : Window
{
public ObservableCollection<gm> data1 = new ObservableCollection<gm>();
public MainWindow()
{
InitializeComponent();
}
// public ObservableCollection<gm> data { get { return data1; } }
private void button1_Click_1(object sender, RoutedEventArgs e)
{
data1.Add(new gm() { no = 2, name = "vipul" });
dataGrid1.ItemsSource = data1.ToArray();
}
}
public class gm
{
public int no { get; set; }
public string name { get; set; }
}
}
when i am execute above code it add blank row in datagrid please give me solution of this problem i want to know how to add row in datagird run time.
thanks in advance