Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Error when using datagridcolumnheader with in header template

$
0
0

I'm trying to use this code to create "grouped columns" in DataGrid

<toolkit:DataGrid ItemsSource="{Binding }" Name="dataGrid1" AutoGenerateColumns="False" 
                          ColumnHeaderHeight="50" > <toolkit:DataGrid.Resources><Style x:Key="DataGridColumnHeader" TargetType="{x:Type toolkit:DataGridColumnHeader}"><Setter Property="VerticalContentAlignment" Value="Center" /><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type toolkit:DataGridColumnHeader}"><Grid><ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" /></Grid></ControlTemplate></Setter.Value></Setter></Style></toolkit:DataGrid.Resources><toolkit:DataGrid.Columns><toolkit:DataGridTextColumn Binding="{Binding ID}" Header="ID" Width="60"/><toolkit:DataGridTextColumn Binding="{Binding Name}" Header="Name" Width="60"/><toolkit:DataGridTextColumn Binding="{Binding Country}" Header="Country" Width="60" 
                                            HeaderStyle="{StaticResource DataGridColumnHeader}"> <toolkit:DataGridTextColumn.HeaderTemplate><DataTemplate><StackPanel Orientation="Vertical"><TextBlock   Width="60"/><toolkit:DataGridHeaderBorder  Height="2" Background="Black" /><toolkit:DataGridColumnHeader Content="Country" Width="60"/></StackPanel></DataTemplate></toolkit:DataGridTextColumn.HeaderTemplate></toolkit:DataGridTextColumn><toolkit:DataGridTextColumn Binding="{Binding City}" Header="City" Width="60"
                                             HeaderStyle="{StaticResource DataGridColumnHeader}"><toolkit:DataGridTextColumn.HeaderTemplate><DataTemplate><StackPanel Orientation="Vertical"><TextBlock  Text="Address"/><toolkit:DataGridHeaderBorder  Height="2" Background="Black" /><toolkit:DataGridColumnHeader Content="City" Width="60" /></StackPanel></DataTemplate></toolkit:DataGridTextColumn.HeaderTemplate></toolkit:DataGridTextColumn><toolkit:DataGridTextColumn Binding="{Binding Street}" Header="Street" Width="60"
                                             HeaderStyle="{StaticResource DataGridColumnHeader}"><toolkit:DataGridTextColumn.HeaderTemplate><DataTemplate><StackPanel Orientation="Vertical"><TextBlock /><toolkit:DataGridHeaderBorder  Height="2" Background="Black" /><toolkit:DataGridColumnHeader Content="Street" Width="60"/></StackPanel></DataTemplate></toolkit:DataGridTextColumn.HeaderTemplate></toolkit:DataGridTextColumn> </toolkit:DataGrid.Columns></toolkit:DataGrid>

It displays as expected but whenever I hover to the DataGridColumnHeaders, an error occurs. I'm using the latest release of WPF Toolkit datagrid as I am stuck on .NET 3.5 SP1.

Maybe someone has encountered this and knows a solution/workaround, please let me know.

Another possible answer would be an alternative to implementing the grouped columns (like above) without using third party controls.

Thanks


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>