Reputation: 71
I'm having troubles in getting a grid to work:
I want to let users add rows but when the program is compiled the CanUserAddRows
is set to false. - SOLVED
Another problem I'm facing is when the user edits the grid, it isn't applying what has been changed; although the delete is working fine.
How can I solve this?
public ObservableCollection<BolaInfo> bolas;
public IniciaSim()
{
this.InitializeComponent();
this.bolas = new ObservableCollection<BolaInfo>();
}
private void Introduzir_Click(object sender, RoutedEventArgs e)
{
if (rendering)
{
plotCanvas.Children.Clear();
CompositionTarget.Rendering -= RenderFrame;
rendering = false;
}
DataGrid dados = new DataGrid();
dados.Width = plotCanvas.ActualWidth;
dados.Height = plotCanvas.ActualHeight;
dados.ColumnWidth = 128;
dados.IsReadOnly = false;
dados.IsEnabled = true;
dados.AutoGenerateColumns = true;
dados.CanUserResizeColumns = false;
dados.CanUserReorderColumns = false;
dados.CanUserAddRows = true;
dados.CanUserDeleteRows = true;
dados.ItemsSource = bolas;
}
Upvotes: 0
Views: 167
Reputation: 1138
Check if BolaInfo class has a contructor without parameters. I think you can only add rows automatically if the class can create a new instance without parameters.
Upvotes: 1