locked
Remove spaces from datagrid header RRS feed

  • Question

  • Is there any way I can remove the unwanted spaces (used for sorting, and the extra padding from silverlight datagrid?

    I tried using the following code, but the is still some space at the right side of the header... Is there any other property I need to set to remove that?

    <data:DataGridTemplateColumn Width="20" CanUserResize="False" CanUserReorder="False">
                                            <data:DataGridTemplateColumn.HeaderStyle>
                                                <Style TargetType="<data:DataGridTemplateColumn Width="20" CanUserResize="False" CanUserReorder="False">
                                            <data:DataGridTemplateColumn.HeaderStyle>
                                                <Style TargetType="primitives:DataGridColumnHeader">
                                                    <Setter Property="Padding" Value="0"/>
                                                    <Setter Property="Margin" Value="0"/>
                                                    <Setter Property="ContentTemplate">
                                                        <Setter.Value>
                                                            <DataTemplate>
                                                                <StackPanel Orientation="Horizontal">
                                                                    <Button Style="{StaticResource MyButtonStyle}" Command="{Binding Path=MyCommand, Source={StaticResource ViewModel}}" />
                                                                </StackPanel>
                                                            </DataTemplate>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Style>
                                            </data:DataGridTemplateColumn.HeaderStyle>
                                            <data:DataGridTemplateColumn.CellTemplate>
                                                <DataTemplate/>
                                            </data:DataGridTemplateColumn.CellTemplate>
                                        </data:DataGridTemplateColumn>">


    Tuesday, July 12, 2011 11:57 PM

Answers

  • Figured it out by myself... Sorry for the post!

    Use Template as well... Not sure whether this is the right method... but its working

    <Setter Property="Template">       
    <Setter.Value>
    <ControlTemplate TargetType="primitives:DataGridColumnHeader"> <Grid Name="Root"> <ContentPresenter x:Name="HeaderText" Content="{TemplateBinding Content}" Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" /> </Grid> </ControlTemplate> </Setter.Value> </Setter>


    Wednesday, July 13, 2011 1:45 AM