Stackable Columns

Nov 26, 2008 at 9:24 PM
Hello, I am new to WPF and the Datagrid so forgive me if this has been discussed before.  Is it easly possible to stack columns on top of each other so that a row of data would be composed of two rows?  Or does this require a complete DataTemplate Customization?  Thanks again and sorry if this has been discussed before.
Dec 1, 2008 at 5:29 PM
Hi keithwilliams324,

I'm not sure if I understand what you're asking for exactly, but maybe are you looking for RowDetails?  You can set the RowDetailsTemplate to include additional information for a row in whatever format you choose (whether it's another row, just a TextBlock, or a whole DataGrid).  You can use RowDetailsTemplate like so:

          ... this is where you put your second row ...                    

Does that help at all?

Dec 4, 2008 at 2:03 PM
I got it working thanks!  What I used is the DataGridTemplateColumn for my columns and stacked two textboxes to get the effect I am looking for.  As a follow up question though, I am also using the Ribbon Control and once it my window is inherited from RibbonWindow my columns on my DataGrid ignored the Width property set to "Auto" and now default to some small width.  Any ideas?  Thank you again.
Dec 4, 2008 at 6:10 PM
Hmm, that's definitely strange behavior.  I've made quite a few demo apps with Ribbon and DataGrid in a RibbonWindow and haven't had this problem.  I usually structure my app something like:

               <RowDefinition Height="Auto"/>
               <RowDefinition Height="*"/>

          <Ribbon Grid.Row="0"/>
          <DataGrid Grid.Row="1"/>

If you could send your XAML, I can take a look and see if I notice anything which might be causing a problem.  As a workaround, you can try setting MinWidths on all of the columns to see if that prevents them from getting too small.
Dec 9, 2008 at 4:41 PM
I think I will just set the MinWidths for now thanks