DataGrid Column not shown

Feb 17, 2009 at 1:22 AM
Edited Feb 17, 2009 at 5:38 AM
Hi All,
I have an issue, when I display datagrid in dialog box. Sometimes the column headers are squeezed, I have to resize the column to make it visible.

I bind the DataGrid to my custom collection. The collection contains items loaded from DataRow.

I don't know if anyone has the same problem, its very annoying, my application replies on datagrid alot now.


The only way I can solve this problem is to do something like this:

 

public void ShowEditDialog(RateBandCollection collection)
{

 

//... other codes

//This is workaround for displaying datagrid column headers
    Dispatcher.BeginInvoke(DispatcherPriority.Normal, new ThreadStart(
      delegate
      {
          MainDataGrid.DataContext = collection;
      }
    ));

 

    ShowDialog();
}

// If I do this, headers are squeezed.

public
void ShowEditDialog(RateBandCollection collection)
{

//... other codes

      MainDataGrid.DataContext = collection;
      ShowDialog();
}

 


Jerry