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

selected gridviewrow style does not override the default styling behaviour

1 Answer 181 Views
GridView
This is a migrated thread and some comments may be shown as answers.
anurag
Top achievements
Rank 1
anurag asked on 24 Nov 2010, 07:14 AM
Hi,
 I am trying to override the default selected style for radgridview but it still show me up with the dark orange style selection of the radgridview.

<Window x:Class="HightLighted.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
    <Grid>
        <telerik:RadGridView ItemsSource="{Binding}" Background="Red" Foreground="White" AutoGenerateColumns="False" HorizontalAlignment="Left" Margin="24,36,0,0" Name="radGridView1" VerticalAlignment="Top">
            <telerik:RadGridView.RowStyle>
                <Style TargetType="{x:Type telerik:GridViewRow}">
                    <Setter Property="Background" Value="Red"/>
                    <Setter Property="Foreground" Value="White"/>
                    <Style.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Background" Value="DarkOrange"/>
                            <Setter Property="Foreground" Value="black"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="LightYellow"/>
                            <Setter Property="Foreground" Value="black"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </telerik:RadGridView.RowStyle>
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="EmployeeID" DataMemberBinding="{Binding EmployeeID}"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>
</Window>

1 Answer, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 25 Nov 2010, 01:38 PM
Hello Anurag,


In order to change the behavior of a selected GridViewRow is to edit its template. With a simple style you can override basic properties that a GridViewRow exposes, but not to change its infrastructure. Briefly if you want to change the color of a GridViewRow when it is Selected in its template you should find the Border element named Background_Selected and change the color. In similar way you can change the colors in any other state, in our online documentation you can find a very useful information about Styling a Row.


Attached is an example that demonstrates this approach.


Greetings,
Vanya Pavlova
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
Tags
GridView
Asked by
anurag
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Share this question
or