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

StyleSelector for setting GridViewCell Background color and border color

0 Answers 113 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Lior
Top achievements
Rank 1
Lior asked on 06 Nov 2012, 07:23 AM
Hi,
we've implemented a styleSelector for style switching. but cell backgroupd color and border could not be set 
Style:
<Style x:Key="CellLv1Validation"   TargetType="telerik:GridViewCell">
       <Setter Property="BorderBrush" Value="Red"/>
       <Setter Property="BorderThickness" Value="1" />
       <Setter Property="Background" Value="Yellow"/>
   </Style>

StyleSelector:
  public override Style SelectStyle(object item, DependencyObject container)
 {
            Style style = null;
             Uri uri = new Uri("/Solution.Common;component/Assets/ApplicationStyles.xaml", UriKind.RelativeOrAbsolute);
                    ResourceDictionary converterDictionary = new ResourceDictionary()
                    {
                        Source = uri
                    };
 
              style = converterDictionary["CellLv1Validation"] as Style;
            DataRow dr = item as DataRow ;
            return dr.isNeedStyle ? style : null
}


Another StyleSetter from telerik. but this style is only having border and background color, the text in girdcellview disappear.
<Style x:Key="CellLv1Validation2" TargetType="telerik:GridViewCell" >
            <Setter Property="Background" Value="Red"/>
              <Setter Property="Template">
           <Setter.Value>
            <ControlTemplate TargetType="telerik:GridViewCell">
                 <Border x:Name="PART_CellBorder" BorderBrush="Red" BorderThickness="1" Background="Yellow"/>           
              </ControlTemplate>
           </Setter.Value>
        </Setter>
   </Style>

And I've found a thread to set the Template , but it's complex, What we need is only to set the border color and cell background color,
Any suggestions? thank you in advance. 


No answers yet. Maybe you can help?

Tags
GridView
Asked by
Lior
Top achievements
Rank 1
Share this question
or