In the application I’m developing, I’m using a datagrid to display data fetch from a database. It is declared like so in my XAML file:
<sdk:DataGrid x:Name="dg" AutoGenerateColumns="False" ItemSource={Binding etc.} >
<sdk:DataGrid.Columns>
<sdk:DataGridTextBoxColumn Header="Col1"
Binding="{Binding Col1Data}" />
<sdk:DataGridTextBoxColumn Header="Col2"
Binding="{Binding Col2Data}" />
<sdk:DataGridTextBoxColumn Header="Col3"
Binding="{Binding Col3Data}" />
<sdk:DataGridCheckBoxColumn Header="Col4"
Binding="{Binding Col4Data}" />
<sdk:DataGrid.Columns>
<sdk:DataGrid>
What I want to do, is to add a row, containing 5 combo boxes (1 for each column) between the header and the first row of my data. It is pretty easy to do for a column, using DataGridTemplateColumn, but how can I do this for a row?
Thanks in advance for your suggestions!
Fake edit: Oh by the way I’m not a fan of code behind (trying to go full MVVM), so I’m looking for a way to do this in XAML, if possible.
Ok, so I kinda found a work around. I declared a template for my cells that contains a button and a textblock bound to the data. i bind the visibility property of the button on a boolean that will be true only for the elements of the first row.
It’s a bit hack-ish. But it works. My only concern is performance since a button is declared for each cell. So with thousands of row, I guess there could be a performance hit.