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

Why is the first row formatting differently?

9 Answers 561 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 25 Mar 2012, 02:58 AM
I have recently implemented themes in my application.  The application has two themes, Day & Night.  The application changes themes by loading a ResourceDictionary that defines different colors for the same named SolidColorBrush DynamicResources.

Here is the xaml for the style I'm using for the rows in the all of the RadGridView controls in my application.  This is in the app,xaml file:
<Style TargetType="telerik:GridViewRow">
    <Setter Property="Background"
            Value="{DynamicResource TextBackground}" />
    <Setter Property="Foreground"
            Value="{DynamicResource TextForeground}" />
</Style>

I think the first row is probably the row used to insert new rows into the Grid.  Here's the XAML for one of my RadGridControls:

<telerik:RadGridView AutoExpandGroups="True"
                     AutoGenerateColumns="False"
                     Background="{DynamicResource DataBackground}"
                     CanUserDeleteRows="False"
                     CanUserFreezeColumns="False"
                     CanUserInsertRows="False"
                     CanUserResizeColumns="False"
                     CanUserSortColumns="True"
                     EnableColumnVirtualization="True"
                     EnableRowVirtualization="True"
                     FontSize="16"
                     FontWeight="Bold"
                     Foreground="{DynamicResource DataForeground}"
                     Grid.Column="1"
                     Grid.ColumnSpan="2"
                     Grid.Row="1"
                     IsReadOnly="True"
                     ItemsSource="{Binding Path=DataRetentionPolicies, Mode=TwoWay, RelativeSource={RelativeSource AncestorType={x:Type cs:AdvancedSettingEditor}}}"
                     Margin="5"
                     Name="DataPolicies"
                     SelectionUnit="FullRow"
                     ScrollMode="Deferred"
                     ScrollViewer.CanContentScroll="True"
                     ScrollViewer.HorizontalScrollBarVisibility="Auto"
                     ScrollViewer.VerticalScrollBarVisibility="Auto"
                     ShowGroupFooters="True"
                     TabIndex="8"
                     ToolTip="Data Maintenance Properties"
                     Visibility="{Binding Converter={StaticResource BoolToVisibility}, Mode=TwoWay, Path=EnableRetention, RelativeSource={RelativeSource AncestorType={x:Type cs:AdvancedSettingEditor}}}">
    <telerik:RadGridView.Columns>
        . . .
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

As you can see, the control is read-only and it doesn't allow inserting, editing or deleting of rows.

In the Day theme, the rows in my RadGridView have black text on white backgrounds. In the Day theme, they're supposed to have yellow text on black backgrounds. And every row in the DataGridControl matches this color scheme exept the first, which still has a white background.

How do I get the first row's background to change with the other rows?
Tony

9 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 26 Mar 2012, 07:07 AM
Hi,

 This is actually the grid current row. If you do not want this state you can edit the GridViewRow template in blend and remove the unwanted state. 

All the best,
Vlad
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Tony
Top achievements
Rank 1
answered on 26 Mar 2012, 03:23 PM
It is not the currently selected grid row.  The color for that row has an orange color and I can see that color change when I click on other rows.  The first row always has a white background.  Further, the row header to the left has a greater than sign (">") in it.

I do need the selected state.  I need to change the colors for that state, but I do need it.

Tony
0
Tony
Top achievements
Rank 1
answered on 26 Mar 2012, 06:08 PM
I've been able to resolve this issue.

I had created a style for the RadGridRow class.  I changed the TargetType to RadGridCell and now they're all displaying the way I want them to.

Tony
0
Tony
Top achievements
Rank 1
answered on 27 Jul 2012, 06:33 PM
This issue is now back, as I had to get rid of the custom style for the GridViewCell class to get my custom RowStyleSelector class to work.  That is, while I had a custom GridViewCell style, the styles used by my custom RowStyleSelector class were for the GridViewRow class.  The GridViewCell would override the settings for the GridViewRow.

I've had no luck getting the selected state to appear with the colors I want it to have.  What information can I provide that will help you to help me?

Tony
0
Vlad
Telerik team
answered on 30 Jul 2012, 05:45 AM
Hi,

 Have you tried to modify the template of GridViewRow using Blend in the way you want?

Regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Tony
Top achievements
Rank 1
answered on 31 Jul 2012, 02:34 PM
Yes, I did.  Several times.  I'm not having any luck with it at all.  Which has been my experience in trying to customize your templates.  They are so complicated and if there's any documentation, I haven't found it.

For example, I was told that I had to change the Background_Selected element in the GridViewRow template.  I have done so, but the colors I chose are not displaying.  I set the Background property of this element to Blue:

<Border x:Name="Background_Selected"
        BorderBrush="{DynamicResource DataBorderSelected}"
        BorderThickness="1"
        Grid.ColumnSpan="2"
        Grid.Column="2"
        CornerRadius="1"
        Margin="1,1,1,2"
        telerik:SelectiveScrollingGrid.SelectiveScrollingClip="True"
        Visibility="Collapsed">
    <Border Background="{DynamicResource DataBackgroundSelected}"
            BorderBrush="White"
            BorderThickness="1" />
    </Border>
</Border>

The color I get instead is an orangy yellow.  Clearly some other setting / template is conflicting with the change I made.  The question is which one?

I'm using build 2012.1.326.40, by the way.

Tony
0
Maya
Telerik team
answered on 03 Aug 2012, 11:34 AM
Hi Tony,

I would recommend you to run through our documentation for a reference. 

All the best,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Matthew
Top achievements
Rank 1
answered on 14 Aug 2012, 11:13 PM

I was having a similar issue with the first GridViewRow ignoring style, control template and binding in general. I had set PresentationTraceSources.TraceLevel=High on a number of bindings which produces output to the debug window on all rows except the first. The problem  turned out to be not explicitly setting the RadGridView.RowStyle but relying on the style's TargetType.

I feel that this is a bug because I have not seen any documentation in regards to not using TargetType to apply styles.

0
Tony
Top achievements
Rank 1
answered on 07 Dec 2012, 03:09 PM
I was able to fix this problem.  I set the RowIndicatorVisibility property to Hidden and the offending style went away.  While the control's appearance is not exactly what I wanted, it is a vast improvement and is good enough.

Tony
Tags
GridView
Asked by
Tony
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Tony
Top achievements
Rank 1
Maya
Telerik team
Matthew
Top achievements
Rank 1
Share this question
or