WPF DATAGRID EMPTY ROW AT BOTTOM

Ankita Pandey

Total Post:183

Points:1285
Posted by  Ankita Pandey
WPF 
WPF
 5194  View(s)
Ratings:
Rate this:

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?

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: WPF datagrid empty row at bottom

    Hi Ankita,


    If you're creating DataGrid through Source Code...

    DataGrid grid = new DataGrid();

    grid.CanUserAddRows = false;

    //...

    grid.AutoGenerateColumns = false;

    grid.Margin = new Thickness(10,20,10,10);

    grid.VerticalAlignment = VerticalAlignment.Top;

    grid.ItemsSource = //... and so on

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!