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

RowStyleSelector problem

3 Answers 74 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dario
Top achievements
Rank 2
Dario asked on 24 Jan 2013, 12:02 PM

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??

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 24 Jan 2013, 12:54 PM
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.

0
Dario
Top achievements
Rank 2
answered on 24 Jan 2013, 01:25 PM
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? :-)
0
Dimitrina
Telerik team
answered on 24 Jan 2013, 03:02 PM
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.

Tags
GridView
Asked by
Dario
Top achievements
Rank 2
Answers by
Dimitrina
Telerik team
Dario
Top achievements
Rank 2
Share this question
or