row background color

8 posts, 0 answers
  1. normalham2
    normalham2 avatar
    14 posts
    Member since:
    Nov 2006

    Posted 20 Jul 2010 Link to this post


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

    Thanks,
    Todd
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 21 Jul 2010 Link to this post

    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
  3. DevCraft banner
  4. Juan
    Juan avatar
    13 posts
    Member since:
    Jun 2010

    Posted 05 Aug 2010 Link to this post

    Hi Maya!
    How can I change row backround using binding ? I have several types of items and they should have different background color.
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 05 Aug 2010 Link to this post

    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
  6. Juan
    Juan avatar
    13 posts
    Member since:
    Jun 2010

    Posted 06 Aug 2010 Link to this post

    Thank you Maya,
    But I can't find Telerik.Windows.Examples namespace and source code for UnitPriceConveter used in that demo.
  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 06 Aug 2010 Link to this post

    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
  8. Cristina
    Cristina avatar
    8 posts
    Member since:
    Oct 2010

    Posted 25 Oct 2010 Link to this post

    Hi, this example can be used for RadTreeListView? If feasible, what would the declaration in the <telerik: RadTreeListView?. Thanks
  9. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 28 Oct 2010 Link to this post

    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
Back to Top
DevCraft banner