Defining grid columns with empty ItemsSource crashes blend and app.

Aug 28, 2009 at 1:32 PM

Hi,

I have a very weird problem, if I have a datagrid with defined columns and the ItemsSource binding is null of empty I find that Blend and running the application will hang.

Running the application you can see the column header expand off the screen and to infinity and this is where the app fails. I have tried setting absolute column and grid widths with no success.

<toolkit:DataGrid x:Name="InformationDataGrid" AutoGenerateColumns="False" ItemsSource="{Binding Information, Mode=OneWay}">
  <toolkit:DataGrid.Columns>
    <toolkit:DataGridTextColumn Header="Description" Binding="{Binding Description, Mode=OneWay}" Width="*"/>
  </toolkit:DataGrid.Columns>
</toolkit:DataGrid>

Also when the item source is not empty the app works perfectly fine. I am using the latest July Toolkit, XP and Visual Studio SP1, Blend etc.

Can anyone shed some light as to how to resolve please. I know there must be some setup issue with my pc as I am sure others would have experienced this same error..

Thanks

David

 

 

<toolkit:DataGrid x:Name="InformationDataGrid" AutoGenerateColumns="False" ItemsSource="{Binding Information, Mode=OneWay}">
<toolkit:DataGrid.Columns>
<toolkit:DataGridTextColumn Header="Description" Binding="{Binding Description, Mode=OneWay}" Width="*"/>
</toolkit:DataGrid.Columns>
</toolkit:DataGrid>

 

 

 

 

Aug 31, 2009 at 12:16 AM
Edited Aug 31, 2009 at 12:32 AM

Using brute force process of elimination I was able to determine what the problem was. In my global style settings for a button I have found that setting a margin on a button will cause the data grid column headers to expand to infinity and hang Blend. I hope this helps someone fix the problem for the next WPF Toolkit release.

 

<Style TargetType="{x:Type Button}">
  <Setter Property="Margin" Value="2"/>
</Style>

Can anyone else replicate to make sure I am not going mad?

Thanks

David

 

 

 

Nov 16, 2009 at 3:14 PM

I currently am getting an issue with columns going to infinity, I believe it is linked to the * for width and the grid living in a scroll viewer with out a width defined on it.  As soon as I apply a hard coded with it I do not get the exception.

Jan 4, 2010 at 5:40 PM
Edited Jan 4, 2010 at 5:41 PM

We have the exact same problem (setting a button style with margin)

Has this been raised as an issue?