Theme mod

4 posts, 1 answers
  1. Jonathan Miller
    Jonathan Miller avatar
    57 posts
    Member since:
    Jun 2008

    Posted 20 Nov 2008 Link to this post

    Is there a way I can modify the colors on the simple theme?

    (using the grid) When an item is highlighted, I want the text color to be white instead of black.  Thanks
  2. Answer
    Rosi
    Admin
    Rosi avatar
    2529 posts

    Posted 21 Nov 2008 Link to this post

    Hello Jonathan,

    If you want the Style of a GridViewRow to change in response to property changes I suggest you define Triggers for the Style change.

    The following code illustrates how you can change the TextBlock.ForeGround property of the GridViewRow when it is selected or hovered:

     <Window.Resources> 
            <Style TargetType="{x:Type telerik:GridViewRow}">  
                <Setter Property="TextBlock.Foreground" Value="Red" /> 
                <Style.Triggers> 
                    <Trigger Property="IsMouseOver" Value="True"><!--this will change the style when the row is hovered--> 
                        <Setter Property="TextBlock.Foreground" Value="Blue" /> 
                    </Trigger> 
                    <Trigger Property="IsSelected" Value="True"><!--this will change the style when the row is selected--> 
                        <Setter Property="TextBlock.Foreground" Value="Green" /> 
                    </Trigger> 
                </Style.Triggers> 
            </Style> 
        </Window.Resources> 

    Regards,
    Rosi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Jonathan Miller
    Jonathan Miller avatar
    57 posts
    Member since:
    Jun 2008

    Posted 24 Nov 2008 Link to this post

    Thank you for the assist.  The triggers work great with a small exception - my data is in a hierarchy.  The parent rows aren't changing colors, only the children.  Any ideas?
  4. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 26 Nov 2008 Link to this post

    Hello Jonathan Miller,

    Thanks for the feedback. The issue you reported is actually a bug in our theme, so I updated your Telerik points.

    I've fix templates for the GridViewExpandableRow and HierarchyChildPresenter controls in order to take care about the foreground of the parent object.


    <ControlTemplate x:Key="GridViewExpandableRowTableTemplate" TargetType="{x:Type telerik:GridViewExpandableRow}"
            <Border Margin="0" Background="{TemplateBinding Background}" HorizontalAlignment="Left" Width="{Binding Path=VisibleColumnsWidth, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type grid:GridViewItemsControl}}}"
                <Border Name="SelectionBackground" Margin="0" Opacity="1" BorderThickness="0,1,0,1" VerticalAlignment="Top" BorderBrush="#0000BBFF"
                    <Border.Background> 
                        <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1"
                            <GradientStop Color="#0000308F" Offset="0"/> 
                            <GradientStop Color="#00000000" Offset="1"/> 
                            <GradientStop Color="#00000510" Offset="0.501"/> 
                            <GradientStop Color="#00006290" Offset="0.504"/> 
                        </LinearGradientBrush> 
                    </Border.Background> 
                    <Grid> 
                        <Grid.ColumnDefinitions> 
                            <ColumnDefinition Width="Auto"/> 
                            <ColumnDefinition/> 
                        </Grid.ColumnDefinitions> 
                        <telerik:NavigationPresenter x:Name="PART_NavigationPresenter" Grid.Column="0" /> 
     
                        <telerik:HierarchyChildPresenter x:Name="PART_HierarchyChildPresenter" Grid.Column="1" Foreground="{TemplateBinding Foreground}" /> 
                    </Grid> 
                </Border> 
            </Border> 
     
            <ControlTemplate.Triggers> 
     
                <Trigger Property="IsSelected" Value="True"
                    <Setter Property="Background" TargetName="SelectionBackground" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/> 
                </Trigger> 
            </ControlTemplate.Triggers> 
        </ControlTemplate> 
     
    <ControlTemplate x:Key="HierarchyChildPresenterTableTemplate" TargetType="{x:Type telerik:HierarchyChildPresenter}"
            <grid:HorizontalScrollPanel Grid.Row="1" x:Name="PART_PartialScrollContainer" > 
                <Expander x:Name="PART_Expander" IsExpanded="{Binding Path=IsExpanded, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:GridViewExpandableRow}}}" Background="Transparent" Style="{StaticResource GridViewExpandableRowExpanderStyle}"  > 
                    <Expander.Header> 
                        <Grid Name="PART_RowGrid" TextBlock.Foreground="{TemplateBinding Foreground}"
                            <Grid.RowDefinitions> 
                                <RowDefinition Height="Auto" MinHeight="22" /> 
                            </Grid.RowDefinitions> 
                        </Grid> 
                    </Expander.Header> 
                </Expander> 
            </grid:HorizontalScrollPanel> 
        </ControlTemplate> 

    You can use this modified templates to achieve your goals. Or you can use modified version of the Telerik.Windows.Controls.Simple.dll which I'm attaching as part of a sample project.

    If you have any further questions, please let me know.

    Sincerely yours,
    Nedyalko Nikolov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top