开发者

SL4 - TextTrimming in DataGridRowGroupHeader

I'm customizing the DataGridRowGroupHeader in our project. Everything works fine except that I can't get the text to trim.

Here's the style:

            <sdk:DataGrid.RowGroupHeaderStyles>
            <Style TargetType="sdk:DataGridRowGroupHeader">
                <Setter Property="Cursor" 开发者_Python百科Value="Arrow" />
                <Setter Property="IsTabStop" Value="False" />
                <Setter Property="Background" Value="Transparent" />
                <Setter Property="Height" Value="20"/>
                <Setter Property="Margin" Value="18,0,20,0"/>
                <Setter Property="IsEnabled" Value="False"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="sdk:DataGridRowGroupHeader">
                            <Grid Name="Root" 
                                Margin="{TemplateBinding Margin}"
                                Background="{TemplateBinding Background}"
                                HorizontalAlignment="Stretch"
                                >
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="CurrentStates">
                                        <VisualState x:Name="Regular"/>
                                        <VisualState x:Name="Current">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>

                                <Border BorderBrush="Yellow" BorderThickness="1" Visibility="Visible">

                                <TextBlock x:Name="txbGroupingName"
                                    Margin="4,0,0,0" 
                                    Text="{Binding Name}" 
                                    FontSize="13" 
                                    TextTrimming="WordEllipsis"
                                    HorizontalAlignment="Left"
                                    Style="{StaticResource OrangeBodyText}"
                                    />

                                </Border>

                                <Rectangle Name="FocusVisual" 
                                    Stroke="{StaticResource BorderFocusBrush}" 
                                    StrokeThickness="1" 
                                    HorizontalAlignment="Stretch" 
                                    VerticalAlignment="Stretch" 
                                    IsHitTestVisible="false" 
                                    Opacity="0" />

                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </sdk:DataGrid.RowGroupHeaderStyles>

The text in the TextBlock txbGroupingName won't trim and it seems like it should just fine.

Thanks in advance!


I got an answer from Yifung Lin. The RowGroupHeader is fixed to the width of the row. It's intended that a horizontal scrollbar appears when the DataGrid content is too long, and the RowGroupHeaders can be viewed this way. It's when the columns are frozen that the problem appears.

Thus there is no solution really, but this is the reason why the text won't trim dynamically. A width can be set on the textblock to force trimming, but that would probably work better for wrapping.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜