如何将图像添加到DataGrid组头

时间:2012-05-09 07:41:49

标签: wpf datagrid groupstyle

我使用以下代码段对DataGrid进行分组:                                                                                                                                                                                

    <DataGrid.GroupStyle>
        <GroupStyle>
            <GroupStyle.HeaderTemplate>
                <DataTemplate>
                    <StackPanel>
                        <TextBlock Text="{Binding Path=City}" FontWeight="Bold" Padding="3"/>
                    </StackPanel>
                </DataTemplate>
            </GroupStyle.HeaderTemplate>
            <GroupStyle.ContainerStyle>
                <Style TargetType="{x:Type GroupItem}">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type GroupItem}">
                                <Expander>
                                    <Expander.Header>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding Path=Name}" />
                                            <TextBlock Text="{Binding Path=ItemCount}" Margin="8,0,4,0"/>
                                            <TextBlock Text="Element(s)"/>
                                        </StackPanel>
                                    </Expander.Header>
                                    <ItemsPresenter />
                                </Expander>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </GroupStyle.ContainerStyle>
        </GroupStyle>
    </DataGrid.GroupStyle>
</DataGrid>

现在我想在每个组头中都有一个图像 - 是否可以,我该如何插入?

0 个答案:

没有答案
相关问题