RowStyleSelector problem

4 posts, 0 answers
  1. Dario
    Dario avatar
    61 posts
    Member since:
    Apr 2011

    Posted 24 Jan 2013 Link to this post

    Hi all,

     

    I have read the documentation about RowStyleSelectors, I'm using it in my RadGridView but i'm getting a different result: I don't see the whole row with its background but it seems only the border.

     

    I use my telerik:RadGridView in this way:

     

    <telerik:RadGridView AutoGenerateColumns="False"  RowStyleSelector="{StaticResource contactStyleSelector}"
                                 ShowGroupPanel="True" IsFilteringAllowed="True" IsReadOnly="True"
                                 ItemsSource="{Binding ItemListView,Mode=TwoWay}"
                                 Grid.Row="3" x:Name="GridViewContatti">
     
    <telerik:GridViewDataColumn Width="Auto"  IsReadOnly="True" DataMemberBinding="{Binding RagioneSocialeCompleta}" />
     
    <telerik:GridViewDataColumn Width="Auto"  IsReadOnly="True"DataMemberBinding="{Binding Indirizzo}" />
     
    </telerik:RadGridView>

     

    Which is the problem??

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 24 Jan 2013 Link to this post

    Hello,

    What Style will be applied depends on what Style you have defined. You can check the online demo where you will see that the background for the entire row changes when the Style is applied. How have you defined the Style returned by the RowStyleSelector?

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Dario
    Dario avatar
    61 posts
    Member since:
    Apr 2011

    Posted 24 Jan 2013 Link to this post

    Ok,
    this is the Style Selector

    namespace CRMClient.Utility
    {
        public class ContattoStyleSelector : StyleSelector
        {
            public override Style SelectStyle(object item, DependencyObject container)
            {
                if (item is Contact)
                {
                    Contact cont = item as Contact;
     
                    if (cont.HasErrors)            
                    {
                        return IncompleteStyle;
                    }
                    else
                    {
                        return CompleteStyle;
                    }
                }
                return null;
            }
            public Style IncompleteStyle { get; set; }
            public Style CompleteStyle { get; set; }
        }

    this is the style

    <utility:ContattoStyleSelector x:Key="contactStyleSelector">
        <utility:ContattoStyleSelector.IncompleteStyle>
            <Style TargetType="telerik:GridViewRow">
                <Setter Property="Background" Value="Red" />
                
            </Style>
        </utility:ContattoStyleSelector.IncompleteStyle>
     
        <utility:ContattoStyleSelector.CompleteStyle>
            <Style TargetType="telerik:GridViewRow">
                <Setter Property="Background" Value="White"/>
            </Style>
        </utility:ContattoStyleSelector.CompleteStyle>
     
    </utility:ContattoStyleSelector>

    Where is the error? :-)
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 24 Jan 2013 Link to this post

    Hello,

    The code looks perfect. Have you defined a Style targeting GridViewCell with a White Background? 

    Kind regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top