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

row background color

7 Answers 110 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
normalham2
Top achievements
Rank 1
normalham2 asked on 20 Jul 2010, 10:12 PM

How do I change the row background color for the parent row, and a different row background color for the child rows?

Thanks,
Todd

7 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 21 Jul 2010, 12:20 PM
Hello normalham2,

You may define two different styles with TargetType - GridViewRow and apply each of them to the desired grid using the RowStyle Property. For example:

<UserControl.Resources>      
   <Style x:Key="childRowStyle" TargetType="telerik:GridViewRow">
       <Setter Property="Background" Value="AliceBlue" />
   </Style>
   <Style x:Key="parentRowStyle" TargetType="telerik:GridViewRow">
       <Setter Property="Background" Value="Bisque" />
   </Style>
</UserControl.Resources>

And then:
<telerik:RadGridView Name="playersGrid"                                 
                    RowStyle="{StaticResource childRowStyle}"
                    ItemsSource="{Binding Players}" />

<telerik:RadGridView Name="clubsGrid"
           RowStyle="{StaticResource parentRowStyle}"
           ItemsSource="{Binding Clubs}" />




Sincerely yours,
Maya
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
Juan
Top achievements
Rank 1
answered on 05 Aug 2010, 12:45 PM
Hi Maya!
How can I change row backround using binding ? I have several types of items and they should have different background color.
0
Maya
Telerik team
answered on 05 Aug 2010, 12:56 PM
Hi Juan,

In this case, depending on your exact requirements, you may consider using Conditional Styling and developing different StyleSelectors on different rows. You may find an example on how to do that in our demos.  

All the best,
Maya
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
Juan
Top achievements
Rank 1
answered on 06 Aug 2010, 06:26 AM
Thank you Maya,
But I can't find Telerik.Windows.Examples namespace and source code for UnitPriceConveter used in that demo.
0
Vlad
Telerik team
answered on 06 Aug 2010, 06:59 AM
Hello,

 If you download our demos you can find these classes in StyleSelectors folder. Here is the code for UnitPriceConveter:

public class UnitPriceConveter : IValueConverter
    {
        #region IValueConverter Members
 
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            Products product = value as Products;
 
            if (product != null)
            {
                return product.UnitPrice > 30 ? true : false;
            }
 
            return null;
        }
 
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
 
        #endregion
    }

Sincerely yours,
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
Cristina
Top achievements
Rank 1
answered on 25 Oct 2010, 03:09 PM
Hi, this example can be used for RadTreeListView? If feasible, what would the declaration in the <telerik: RadTreeListView?. Thanks
0
Vlad
Telerik team
answered on 28 Oct 2010, 02:44 PM
Hello Cristina,

 You can check our online demos for more info. 

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
Tags
TreeListView
Asked by
normalham2
Top achievements
Rank 1
Answers by
Maya
Telerik team
Juan
Top achievements
Rank 1
Vlad
Telerik team
Cristina
Top achievements
Rank 1
Share this question
or