This question is locked. New answers and comments are not allowed.
Hi
I want to globally set header wrapping to wrap from the Resource template. I've come close but have an issue with the binding in the DataTemplate I've created for the ContentControl. Any help on correcting the path would be great
My current binding brings back the element name (I think?) System.Windows.Controls.TextBlock
I want to globally set header wrapping to wrap from the Resource template. I've come close but have an issue with the binding in the DataTemplate I've created for the ContentControl. Any help on correcting the path would be great
My current binding brings back the element name (I think?) System.Windows.Controls.TextBlock
<!--NewDataTemplate for text in ContentPresenter--> <DataTemplate x:Key="DataTemplate1"> <TextBlock Text="{Binding Content, ElementName=ContentPresenter}" TextWrapping="Wrap"/> </DataTemplate> <!--End-->
<ControlTemplate x:Key="GridViewHeaderCellTemplate" TargetType="grid:GridViewHeaderCell"> <Grid x:Name="PART_HeaderCellGrid"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal" /> <VisualState x:Name="MouseOver"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GridViewHeaderCell_Over" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="00:00:00"> <DiscreteObjectKeyFrame.Value> <Visibility>Visible</Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="Ascending"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground"> <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource StrongBrush}"/> </ObjectAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_SortIndicator" Storyboard.TargetProperty="Opacity"> <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="1" /> </DoubleAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GridViewHeaderCell_Selected" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="00:00:00"> <DiscreteObjectKeyFrame.Value> <Visibility>Visible</Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="Descending"> <Storyboard> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_SortIndicator" Storyboard.TargetProperty="Opacity"> <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="1" /> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="PART_SortIndicator"> <EasingDoubleKeyFrame KeyTime="0:0:0" Value="180"/> </DoubleAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GridViewHeaderCell_Selected" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="00:00:00"> <DiscreteObjectKeyFrame.Value> <Visibility>Visible</Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Border x:Name="GridViewHeaderCell" Grid.ColumnSpan="2" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" /> <Border x:Name="GridViewHeaderCell_Over" Opacity="0.1" Grid.ColumnSpan="2" Background="{StaticResource StrongBrush}" BorderBrush="Transparent" Visibility="Collapsed" /> <Border x:Name="GridViewHeaderCell_Selected" Grid.ColumnSpan="2" Margin="0,0,1,1" Background="{StaticResource BasicBrush}" BorderBrush="Transparent" Visibility="Collapsed" /> <ContentControl x:Name="ContentPresenter" Grid.Column="0" Foreground="{TemplateBinding Foreground}" Style="{StaticResource StretchedContentControl}" Margin="{TemplateBinding Padding}" IsTabStop="{TemplateBinding IsTabStop}" Content="{TemplateBinding Content}" ContentTemplate="{StaticResource DataTemplate1}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />