문제

I have a RadGridView with groups, and in the header of group I am setting up a data template with a TextBlock bound to a property that contains large strings (less than 500 char). I have set the TextBlock to wrap its text, but no matter what I try, the text scrolls off to the right, but if I scroll the grid to the right, the group header doesnt scroll with it, so I cant read the info.

The only thing I've managed to do, is set the width of the TextBlock to a fixed width, and then it wraps, but because its a fixed width, it doesnt do well when I change the size of the browser window.

Any ideas?

Here is the XAML:

<telerik:RadGridView x:Name="grdNotams" Grid.Row="1" AutoGenerateColumns="False" RowIndicatorVisibility="Collapsed" ShowGroupPanel="False" GroupRowIsExpandedChanging="grdNotam_GroupRowIsExpandedChanging">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Header="Status" UniqueName="colStatus" DataMemberBinding="{Binding Model.Status}" HeaderTextAlignment="Center" TextAlignment="Center" IsFilterable="False" IsSortable="False"/>
        <telerik:GridViewDataColumn Header="Trip #" UniqueName="colTripNumber" DataMemberBinding="{Binding Model.TripNumber}" HeaderTextAlignment="Center" TextAlignment="Center" IsFilterable="False" IsSortable="False"/>
    </telerik:RadGridView.Columns>
    <telerik:RadGridView.GroupHeaderTemplate>
        <DataTemplate>
            <TextBlock Text={Binding BigText} TextWrapping="Wrap" />
        <DataTemplate>
    </telerik:RadGridView.GroupHeaderTemplate>
</telerik:RadGridView>

I have also tried things like this:

<DataTemplate>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinitions></ColumnDefinitions>
            <ColumnDefinitions Width=20></ColumnDefinitions>
        </Grid.ColumnDefinitions>
        <TextBlock Text={Binding BigText} TextWrapping="Wrap" />
        <Ellipse Fill="Red" Width="10" Height="10" Margin="5" Grid.Column="1"/>
    </Grid>
</DataTemplate>
도움이 되었습니까?

해결책

The GroupHeaderTemplate is eventually applied to an instance of GridViewGroupRow.

You should be able to define an implicit style for that type, with HorizontalContentAlignment set to Stretch.

<Style TargetType="telerik:GridViewGroupRow">
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top