WPF datagrid empty row at bottom

datagridwpf

I bind my datagrid using

//fill datagrid
public DataTable GameData
{
    get
    {
        DataSet ds = new DataSet();
        FileStream fs = new FileStream(IMDB.WebPage.Class.Config.XMLPath,
        FileMode.Open, FileAccess.Read);
        StreamReader reader = new StreamReader(fs, Encoding.Default);
        ds.ReadXml(reader);
        fs.Close();
        DataTable temp = ds.Tables[0];
        return ds.Tables[0];
     }
 }

For some reason I get an empty row at the bottom. And sometimes after clicking on some buttons and checkboxes in the grid, more empty rows are added.

Why is this? And how do I block this?

Best Answer

Sounds like you probably have CanUserAddRows set to true for the DataGrid. Just add

CanUserAddRows="false"

to the XAML.