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

Selector.IsSelectionActive not working ?

3 Answers 171 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Krijn asked on 27 Jul 2009, 12:45 PM

I noticed that the default RadGridView style does not provide a gray row when a Row is selected but not active; window with both textbox and gridView; select line in gridView; line is blue; activate textbox (click or tab); selected line is still blue.

I tried to modify this behavior inside a GridViewRow style using a Multitrigger but it seems that Selector.IsSelectionActive is always false.

This is my current GridViewRow template : 

   <Style TargetType="{x:Type telerik:GridViewRow}">
            <Setter Property="Template">
                    <ControlTemplate TargetType="{x:Type telerik:GridViewRow}">
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />

                            <Border x:Name="SelectionBackground"
                     Background="{TemplateBinding Background}"
                     MinHeight="{TemplateBinding MinHeight}"
                     BorderBrush="{TemplateBinding BorderBrush}"
                     BorderThickness="{TemplateBinding BorderThickness}"
                     Margin="{TemplateBinding Margin}"
                     Padding="{TemplateBinding Padding}" />

                            <Rectangle x:Name="BackgroundRectangle"
                                       Grid.Column="2" Opacity="0"
                        Fill="{DynamicResource telerik.GridViewRowSelectedBackground}"
                        Stroke="{DynamicResource telerik.GridViewRowSelectedBorderBrush}"
                        StrokeThickness="1" />

                            <telerik:IndicatorPresenter x:Name="PART_IndicatorPresenter" 
                                                        Visibility="{TemplateBinding RowIndicatorVisibility}" Grid.Column="0"
                              Background="{TemplateBinding Background}"

                                <Path x:Name="NavigatorIndicator"
          Fill="#FF000000" Stretch="Fill" Width="5" Height="8" Data="M254.5,183.75 L254.5,193.33333 260.75,188.16682 z"
          Visibility="Collapsed" VerticalAlignment="Center" HorizontalAlignment="Center" />

                            <telerik:IndentPresenter x:Name="PART_IndentPresenter" 
                                                     IndentLevel="{TemplateBinding IndentLevel}"
                                                     Background="{TemplateBinding Background}" />
                            <telerik:DataCellsPresenter  Height="Auto"
                     MinHeight="{TemplateBinding MinHeight}" />

                            <Rectangle Width="Auto" Height="Auto"
                                       Grid.Column="0" Grid.ColumnSpan="3" />

                                    <Condition Property="IsSelected" Value="true"/>
                                    <Condition Property="Selector.IsSelectionActive" Value="false"/>
                                <Setter Property="Fill"
                                        Value="{DynamicResource telerik.GridViewRowSelectedInactiveBackground}"/>
                                <Setter Property="Stroke"
                                        Value="{DynamicResource telerik.GridViewRowSelectedInactiveBorderBrush}"/>

                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="Opacity" TargetName="BackgroundRectangle" Value="1"/>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" TargetName="SelectionBackground" Value="{DynamicResource telerik.GridViewRowMouseOverBackgroundBrush}"/>
                                    <Condition Property="IsSelected" Value="False" />
                                    <Condition Property="IsMouseOver" Value="True" />
                                <Setter Property="Opacity" TargetName="BackgroundRectangle" Value=".5"/>
                            <Trigger Property="IsCurrent" Value="True">
                                <Setter TargetName="NavigatorIndicator" Property="Visibility" Value="Visible" />
                            <Trigger Property="IsContentValid" Value="False">
                                <Setter TargetName="InvalidBorder" Property="Visibility" Value="Visible" />

            <Setter Property="IsTabStop" Value="False" />
            <Setter Property="BorderBrush" Value="{DynamicResource telerik.GridViewRowBorderBrush}" />
            <Setter Property="BorderThickness" Value="0,0,0,0" />
            <Setter Property="Margin" Value="0" />
            <Setter Property="Padding" Value="0" />
            <Setter Property="MinHeight" Value="18" />
            <Setter Property="FontSize" Value="11" />
            <Setter Property="FontFamily" Value="Verdana" />
            <Setter Property="FontWeight" Value="Normal" />
            <Setter Property="Foreground" Value="#FF000000" />

                        <Condition Binding="{Binding Path=IsAlternating, RelativeSource={RelativeSource Self}}" Value="true"/>
                        <Condition Binding="{Binding Path=UseAlternateRowStyle, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type telerik:RadGridView}}}" Value="true"/>
                    <Setter Property="Background" Value="{DynamicResource telerik.GridViewRowAlternatingRowBackground}" />


Do you have any idea how to solve this ?

3 Answers, 1 is accepted

Sort by
Kalin Milanov
Telerik team
answered on 28 Jul 2009, 02:58 PM
Hi Krijn,

Please find attached a sample application which shows the selected row when the grid is disabled. Note that the sample uses binaries from our latest internal build which you should be able to download from your user account.

Sincerely yours,
Kalin Milanov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Top achievements
Rank 1
answered on 28 Jul 2009, 05:02 PM
Sorry I wasn't more clear but it has nothing to do with Enabled/Disabled functionality.

The WPF property Selector.IsSelectionActive is true when a ListItem inside a ItemsControl is both Selected AND has Keyboard Focus.

The default Style for a ListView uses the IsSelectionActive property inside a style Trigger for setting the BackGround color of the selected row to the selection brush background (aero blue, ...)

When the ItemsControl (=RadGridView) does not have Keyboard focus the SelectedItem is still available, this is presented mostly in gray, see TreeView, ListView, Windows Explorer, ...

Detailed steps:

1. Override MainWindow.xaml ( content with :

    Width="640" Height="480"
    <Grid x:Name="LayoutRoot"
            <RowDefinition Height="Auto"/> 
            <RowDefinition Height="*"/> 
        <TextBox Width="250"/> 
        <telerik:RadGridView x:Name="RadGridView1"  
                             ItemsSource="{Binding Collection, Source={StaticResource SampleDataSource}}"/> 

2. Run
3. Select some row
4. Set Keyboard focus inside the TextBox
5. Selection Row color is still the 'Active selection color' and not gray

Kalin Milanov
Telerik team
answered on 31 Jul 2009, 08:15 AM
Hello Krijn,

Thank you for the detailed clarification. Unfortunately the grid currently does not support this behavior. We recongnize it as native for desktop applications and we will be looking for implementing it in an upcoming release.

I apologize for any inconvenience this might cause and thank yo once more for the great feedback.

Kalin Milanov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Asked by
Top achievements
Rank 1
Answers by
Kalin Milanov
Telerik team
Top achievements
Rank 1
Share this question