This is a migrated thread and some comments may be shown as answers.

How to disable cell highlighting in Q2 2010

5 Answers 123 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Helene Lach
Top achievements
Rank 1
Helene Lach asked on 14 Jul 2010, 07:54 PM

In the past I have been using a style snippet I found on this forum to help get rid of the default cell highlighting in my gridviews. I just upgraded to Q2 2010, and the code does not compile any more - it appears AlignmentContentPresenter has been marked obsolete and removed. How can I achieve the same functionality with this new version? Here is the code I use in my styles.xaml:

 

<LinearGradientBrush x:Key="GridViewRowSelectedCell" EndPoint="0.5,1" StartPoint="0.5,0">
     <GradientStop Color="#FFFFFDF9" Offset="0"/>
     <GradientStop Color="#FFFFEDC7" Offset="1"/>
 </LinearGradientBrush>
 <SolidColorBrush x:Key="GridViewDisabledBackground" Color="#FFEEEEEE"/>
 <SolidColorBrush x:Key="GridViewDisabledBorderBrush" Color="#FFBBBBBB"/>
 <ControlTemplate x:Key="GridViewCellTemplate" TargetType="RadGrid:GridViewCell">
     <Border x:Name="PART_CellBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
         <VisualStateManager.VisualStateGroups>
             <VisualStateGroup x:Name="CommonStates">
                 <VisualState x:Name="Normal"/>
                 <VisualState x:Name="Current">
                     <Storyboard>
                         <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_CellBorder" Storyboard.TargetProperty="Background">
                             <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                 <DiscreteObjectKeyFrame.Value>
                                     <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                         <GradientStop Color="#00FFFDF9" Offset="0"/>
                                         <GradientStop Color="#00FFEDC7" Offset="1"/>
                                     </LinearGradientBrush>
                                 </DiscreteObjectKeyFrame.Value>
                             </DiscreteObjectKeyFrame>
                         </ObjectAnimationUsingKeyFrames>
                     </Storyboard>
                 </VisualState>
             </VisualStateGroup>
             <VisualStateGroup x:Name="EditingStates">
                 <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>
                     </Storyboard>
                 </VisualState>
                 <VisualState x:Name="Display"/>
             </VisualStateGroup>
             <VisualStateGroup x:Name="DisabledStates">
                 <VisualState x:Name="Enabled"/>
                 <VisualState x:Name="Disabled">
                     <Storyboard>
                         <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_CellBorder" Storyboard.TargetProperty="Background">
                             <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource GridViewDisabledBackground}"/>
                         </ObjectAnimationUsingKeyFrames>
                         <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_CellBorder" Storyboard.TargetProperty="BorderBrush">
                             <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource GridViewDisabledBorderBrush}"/>
                         </ObjectAnimationUsingKeyFrames>
                     </Storyboard>
                 </VisualState>
             </VisualStateGroup>
         </VisualStateManager.VisualStateGroups>
         <RadGrid:AlignmentContentPresenter x:Name="PART_ContentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Visibility="Visible" Foreground="{TemplateBinding Foreground}" TextAlignment="{TemplateBinding TextAlignment}" TextDecorations="{TemplateBinding TextDecorations}" TextWrapping="{TemplateBinding TextWrapping}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
     </Border>
 </ControlTemplate>
 <SolidColorBrush x:Key="GridLinesFill" Color="#FFB3B3B3"/>
   
 <Style x:Key="GridViewCellStyle" TargetType="RadGrid:GridViewCell">
     <Setter Property="Template" Value="{StaticResource GridViewCellTemplate}"/>
     <Setter Property="Padding" Value="5,0,3,0"/>
     <Setter Property="BorderBrush" Value="{StaticResource GridLinesFill}"/>
     <Setter Property="BorderThickness" Value="0,0,1,0"/>
     <Setter Property="VerticalContentAlignment" Value="Center"/>
     <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
     <Setter Property="Background" Value="Transparent"/>
 </Style>

 

 

 

Thanks in advance for your help.

5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 15 Jul 2010, 06:50 AM
Hi,

 You can edit the same template with Blend and again remove desired states/elements. 

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
0
David Brubacher
Top achievements
Rank 1
answered on 23 Jul 2010, 04:34 PM
Can you elaborate on that a bit? I'm afraid I don't understand how you advice applies.
0
Vlad
Telerik team
answered on 29 Jul 2010, 08:36 AM
Hello,

 The idea is to get the new template exactly in the same way as the old template - from Blend. How did you get the old template?

Best wishes,
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
0
Chris
Top achievements
Rank 1
answered on 13 Oct 2010, 02:41 PM
Hey guys,

one question about this xaml code above.

How can i edit this style from blend? I got exactly the same problem and i´m tried to delete the cell highlighting.

Thanks in advance.

0
Vanya Pavlova
Telerik team
answered on 13 Oct 2010, 03:10 PM
Hello Chris,

Considering the topic how to edit the style of GridViewCell please see the following article Styling a Cell. In addition to this article I have prepared an example for you that demonstrates how to remove states from GridViewCell.

Please see the attached and let me know if you need any additional information.

Regards,
Vanya Pavlova
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
Tags
GridView
Asked by
Helene Lach
Top achievements
Rank 1
Answers by
Vlad
Telerik team
David Brubacher
Top achievements
Rank 1
Chris
Top achievements
Rank 1
Vanya Pavlova
Telerik team
Share this question
or