Prior to Q1 2010 version, I am able to modify the theme files ( Windows 7 theme) and wrap the text content of cells automatically (i.e. TextWrapping is defaulted to Wrap rather than default value of NoWrap). However in Q1 2010 cell “TextWrapping” dependency property is marked obsolete. I understand that I can set “TextWrapping” dependency property in the markup but that is I am trying to avoid having to specify on “TextWrapping” on each GridViewDataColumn in the markup. My User interface requirements are that text content be wrapped by default. How do I style by column/cells in 2010 Q1 version to achieve same functionality?
Here is style declaration that used to work prior to 2010 Q1
<Style
TargetType="grid:GridViewCell">
<Setter Property="Template" Value="{StaticResource GridViewCellTemplate}"/>
<Setter Property="Padding" Value="5,0,3,0"/>
<Setter Property="BorderBrush" Value="{StaticResource GridView_GridLinesItemBorder}"/>
<Setter Property="BorderThickness" Value="0,0,1,0" />
<!-- CHANGE Default to Top
<Setter Property="VerticalContentAlignment" Value="Center" />
-->
<Setter Property="VerticalContentAlignment" Value="Top" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Background" Value="Transparent" />
<!-- CHANGE -->
<Setter Property="TextWrapping" Value="Wrap" />
</Style>
5 Answers, 1 is accepted
You can add TextBlock in the cell template add this property to this TextBlock.
Greetings,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
From 2009 Q3 GridViewCell ControlTemplate
<grid:AlignmentContentPresenter x:Name="PART_ContentPresenter" Margin="{TemplateBinding Padding}" Visibility="Visible"
Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
TextAlignment="{TemplateBinding TextAlignment}" TextWrapping="{TemplateBinding TextWrapping}"
TextDecorations="{TemplateBinding TextDecorations}"
/>
From 2010 Q1 GridViewCell ControlTemplate
<ContentPresenter x:Name="PART_ContentPresenter"
Margin="{TemplateBinding Padding}"
Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
Thanks
Rao
AlignmentContentPresenter caused lots of bugs and performance problems and that why we decided to change this to lightweight version with TextBlock - now the grid will change only the Text property of the TextBlock instead of the cell Content which was slow.
According to your first post you already have defined Template in your style.
Sincerely yours,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
<
ControlTemplate x:Key="GridViewCellTemplate" TargetType="grid:GridViewCell">
<Border x:Name="PART_CellBorder"
Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
BorderBrush="{TemplateBinding VerticalGridLinesBrush}"
BorderThickness="{Binding VerticalGridLinesWidth, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource GridLineWidthToThicknessConverter}, ConverterParameter=Right}">
<vsm:VisualStateManager.VisualStateGroups>
<vsm:VisualStateGroup x:Name="CommonStates">
<vsm:VisualState x:Name="Normal" />
<vsm:VisualState x:Name="Current">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_CellBorder" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GridView_CellBackground_Current}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</vsm:VisualState>
</vsm:VisualStateGroup>
<vsm:VisualStateGroup x:Name="EditingStates">
<vsm:VisualState x:Name="Edited">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_ContentPresenter" Storyboard.TargetProperty="Margin">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="0" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_ContentPresenter" Storyboard.TargetProperty="VerticalAlignment">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Stretch" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_CellBorder" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GridView_CellBackground_Edited}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</vsm:VisualState>
<vsm:VisualState x:Name="Display" />
</vsm:VisualStateGroup>
<vsm:VisualStateGroup x:Name="DisabledStates">
<vsm:VisualState x:Name="Enabled" />
<vsm:VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_CellBorder" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource GridView_CellBackground_Disabled}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</vsm:VisualState>
</vsm:VisualStateGroup>
</vsm:VisualStateManager.VisualStateGroups>
<!--- CHANGE
<ContentPresenter x:Name="PART_ContentPresenter"
Margin="{TemplateBinding Padding}"
Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
-->
<TextBlock x:Name="PART_ContentPresenter"
Margin="{TemplateBinding Padding}"
Text="{TemplateBinding Content}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" TextWrapping="Wrap" />
</Border>
</ControlTemplate>
Can you verify if you have set Width for this column? You can check the attache application for reference.
Kind regards,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
