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

[Solved] Grid Selection Background Issue

1 Answer 101 Views
Grid for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ryan
Top achievements
Rank 1
Ryan asked on 24 Jan 2014, 10:10 PM
I have styled the Grid to match the style of our application. I had to change the selected cell style as well.  The selection of the cell works as expected, however after a cell is deselected, it returns back to the default Telerik style.   I am having a hard time trying to figure out why it isn't returning to the custom style that I have applied.  I have attached an image that shows what is happening.  

Here is the Grid Code:

        <telerikGrid:RadDataGrid Grid.Row="1"
                                 Style="{StaticResource BidsGridStyle}"
                                 ItemsSource="{Binding Details}"
                                 AutoGenerateColumns="False"
                                 SelectionMode="Multiple"
                                 SelectionChanged="RadDataGrid_SelectionChanged"
                                 SelectionUnit="Row"
                                 UserGroupMode="Disabled"
                                 UserColumnReorderMode="None" 
                                 UserFilterMode="Disabled"
                                 UserEditMode="Inline"
                                 Width="1000">
            <telerikGrid:RadDataGrid.Columns>
                <telerikGrid:DataGridTextColumn PropertyName="Code" 
                                                CellContentStyleSelector="{StaticResource ForegroundSelector}"
                                                Header="Code" 
                                                HeaderStyle="{ThemeResource BidsGridHeaderStyle}"
                                                SizeMode="Fixed" 
                                                Width="120" />
                <telerikGrid:DataGridTextColumn PropertyName="Description" 
                                                CellContentStyleSelector="{StaticResource ForegroundSelector}"
                                                Header="Description"
                                                HeaderStyle="{ThemeResource BidsGridHeaderStyle}"/>
                <telerikGrid:DataGridTextColumn PropertyName="Plan" 
                                                CellContentStyleSelector="{StaticResource ForegroundSelector}"
                                                Header="Plan" 
                                                HeaderStyle="{ThemeResource BidsGridHeaderStyle}"
                                                SizeMode="Fixed" 
                                                Width="75" />
                <telerikGrid:DataGridTextColumn PropertyName="Elevation" 
                                                CellContentStyleSelector="{StaticResource ForegroundSelector}"
                                                Header="Elev" 
                                                HeaderStyle="{ThemeResource BidsGridHeaderStyle}"
                                                SizeMode="Fixed" 
                                                Width="50"/>
                <telerikGrid:DataGridTextColumn PropertyName="OptionWithDescription" 
                                                CellContentStyleSelector="{StaticResource ForegroundSelector}"
                                                Header="Option: Description"
                                                HeaderStyle="{ThemeResource BidsGridHeaderStyle}"/>
            </telerikGrid:RadDataGrid.Columns>    
        </telerikGrid:RadDataGrid>

Here is the Grid Style Code:

    <Style x:Key="BidsGridStyle" TargetType="telerikGrid:RadDataGrid">
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Foreground" Value="{ThemeResource ApplicationForegroundThemeBrush}" />
        <Setter Property="GridLinesVisibility" Value="Horizontal" />
        <Setter Property="GridLinesThickness" Value="1" />
        <Setter Property="GridLinesBrush" Value="{ThemeResource LineDividerThemeBrush}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="BorderBrush" Value="Transparent" />
    </Style>
    
    <Style x:Key="BidsGridHeaderStyle" TargetType="gridPrimitives:DataGridColumnHeader">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Foreground" Value="{ThemeResource AlternativeForegroundBrush}" />
        <Setter Property="FontWeight" Value="Bold" />
    </Style>

    <Style TargetType="gridPrimitives:SelectionRegionBackgroundControl">
        <Setter Property="Background" Value="{ThemeResource ListViewItemSelectedBackgroundThemeBrush}"/>
        <Setter Property="BorderBrush" Value="{ThemeResource ListViewItemSelectedBackgroundThemeBrush}"/>
        <Setter Property="BorderThickness" Value="2"/>
    </Style>

    <Style TargetType="gridPrimitives:SelectionRegionBorderControl">
        <Setter Property="BorderBrush" Value="{ThemeResource ListViewItemSelectedBackgroundThemeBrush}"/>
        <Setter Property="Background" Value="{ThemeResource ListViewItemSelectedBackgroundThemeBrush}" />
    </Style>
    
    <Style TargetType="gridPrimitives:DataGridCellsPanel">
        <Setter Property="Background" Value="Red" />
    </Style>

    <resources:CellStyleSelector x:Key="ForegroundSelector">
        <resources:CellStyleSelector.SelectedStyle>
            <Style TargetType="TextBlock">
                <Setter Property="Foreground" Value="White"/>
                <Setter Property="Margin" Value="10"/>
            </Style>
        </resources:CellStyleSelector.SelectedStyle>
        <resources:CellStyleSelector.NormalStyle>
            <Style TargetType="TextBlock">
                <Setter Property="Foreground" Value="{ThemeResource ApplicationForegroundThemeBrush}" />
                <Setter Property="Margin" Value="10"/>
            </Style>
        </resources:CellStyleSelector.NormalStyle>
    </resources:CellStyleSelector>

Thank you in advance. 

1 Answer, 1 is accepted

Sort by
0
Ivaylo Gergov
Telerik team
answered on 28 Jan 2014, 01:34 PM
Hi Ryan,

As I was unable to reproduce this bug with the provided project, could you please clarify if you reference the RadControls for Windows 8.1(if you reference the package for Windows 8.0 in a Windows 8.1 there are some bugs)? If you have used RadControls for Windows 8.0 before, you need to uninstall it and then install the RadControls for Windows 8.1.  
If this does not solve the issue, could you please prepare a project that reproduces this behavior in order to avoid misunderstanding.

I am looking forward to your reply.

Regards,
Ivaylo Gergov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Grid for XAML
Asked by
Ryan
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
Share this question
or