Datagrid made me sad.

Nov 26, 2008 at 2:40 PM
Hello,

First let me say I was very excited to hear that there was a grid availible when I heard about this. I was so happy that finally there would be a better solution the the standard 'ListView GridView' or buy a 3rd party grid. That being said I have run into an issue that I am currently unable to resolve.

When I add the following grid to my xaml file it works just fine.

<my:DataGrid Name="dataGrid1" VerticalAlignment="Bottom" xmlns:my="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit">
</my:DataGrid>  


However this is not a very useful grid. Sadly when I add any column to the grid definition my app locks up. I am not really sure if focus is just lost, or if some thread is blocking or if there some other issue in my project or the grid that is causing it. I get no error messages to investigate, and when I look at the running threads there does not seem to be any blocking going on. In any case it renders my application for all practical purposes unresponsive. Here is the code that will cause this behavior.

<

 

my:DataGrid Name="dataGrid1" VerticalAlignment="Bottom" xmlns:my="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit">
    <my:DataGrid.Columns>
        <my:DataGridTextColumn Header="Header" />
    </my:DataGrid.Columns>
</my:DataGrid>

 

 

We all know that no application can function without at least one grid that with one unbound column with a title of 'Header' so I have had to go back to the old fashioned way of using a ListView and a GridView. This made me very sad. And even though this happened long long ago (yesterday) the pain is still fresh in my mind. ;-)

Has anyone run into this issue?

Brette

Nov 26, 2008 at 2:52 PM
Hi Brette,

Sorry to hear of your pain and anguish. WPF should make you happy !

I created a Windows with the DataGrid you provided as a XAML snippet however everything worked fine for me - the UI did not lock-up, although it did not actually do anything because the UI has no data to display and nothing for me to interact with.

If you still have a problem can you please post a complete example - one that is as simple as possible?

Regards,
Colin E.
(your WPF analgesic)
Nov 26, 2008 at 4:46 PM
Colin,

Thanks for the swift reply! In fact I am not binding to any data either. The code I posted was my complete xaml page out side of the window def... I am however using this in the context of a CompositeWPF application and this xaml is a View in the current module. One thing I will say up front is that the issue I am seeing seems to be related to the project I am working on. If I create a new .sln it seems to work just fine. Thus the old addage of "It is not you it is me" most likley applies ;-) In any case I here is the complete xaml file in question. My guess is if you put this in your project it will work like a champ. As it does for me.

<UserControl x:Class="SFM.Net.Modules.CompRehab.CaseSearch.View.CaseSearchView"
xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml 
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<Grid VerticalAlignment="Stretch"
    HorizontalAlignment="Stretch"
    MinHeight="500"
    Background='{x:Static SystemColors.ControlBrush}'>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"
            MaxHeight="150" />
  <RowDefinition Height="*" />
  </Grid.RowDefinitions>
  <my:DataGrid Grid.Row="1"
   Name="dataGrid1"
   xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit">
   <my:DataGrid.Columns>
    <my:DataGridTextColumn Header="Header" />
   </my:DataGrid.Columns>
  </my:DataGrid>
 </Grid>
</UserControl>