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

Row alternation gets broken by setting VerticalContentAlignment

4 Answers 79 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 22 Jan 2014, 01:26 PM
I have changed a single element in our styles: from Stretch to Top:
    <Style TargetType="telerik:GridViewRow">
         <Setter Property="VerticalContentAlignment" Value="Top"/>
    </Style>

That does work.

But a bizarre side effect is that the row alternation gets broken. Nothing else is changed!
   <Style TargetType="telerik:RadGridView">
        <Setter Property="AlternateRowBackground" Value="{StaticResource Item_AlternateBackground}"/>
        <Setter Property="AlternationCount" Value="2"/>
    </Style>

Is this a bug? Or might there something else that causes this behaviour?

4 Answers, 1 is accepted

Sort by
0
Robert
Top achievements
Rank 1
answered on 22 Jan 2014, 01:36 PM
Correction.

The intended behaviour was NOT achieved by my change.

What did work was the following.
    <Style TargetType="telerik:GridViewCell">
        <Setter Property="VerticalContentAlignment" Value="Top" /> <!-- This is particularly for TraceLogs. -->
        <Setter Property="Padding" Value="5" />
    </Style>

The observed problem remains, but is no longer relevant to me at this moment.
0
Hristo
Telerik team
answered on 27 Jan 2014, 08:00 AM
Hi,

You can fix this problem by setting the VerticalContentAlignment property of GridViewCell as you have already done. You can achieve the same result if you use VerticalAlignment  instead of VerticalContentAlignment.

The main difference between VerticalAlignment and VerticalContentAlignment is that
VerticalAlignment determines the alignment of the control itself with respect to its parent control. However, the VerticalContentAlignment determines the controls content alignment with respect to the control.

When property's value is set to stretch, the element fills the entire layout slot of the parent element. You can find more details on how the different values of the property work here.

Regards,
Hristo
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Robert
Top achievements
Rank 1
answered on 27 Jan 2014, 10:02 AM
Well, yes, that is what I already found out myself. So, no answer to the problem.

What still remains is the matter of the no longer working alternation.

0
Vanya Pavlova
Telerik team
answered on 29 Jan 2014, 02:47 PM
Hello Robert,


By design the implicit style targeted at GridViewRow would not affect alternated rows. RadGridView exposes RowStyle and AlternateRowStyle properties.  If you want to apply a style to normal and alternated rows, please use a style with x:Key and use the corresponding style properties, as shown below:

<Style x:Key="style1" TargetType="telerik:GridViewRow">
         .....
 </Style>
<telerik:RadGridView RowStyle="{StaticResource style1}" AlternateRowStyle="{StaticResource style1}" ..... />
    


Regards,
Vanya Pavlova
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Robert
Top achievements
Rank 1
Answers by
Robert
Top achievements
Rank 1
Hristo
Telerik team
Vanya Pavlova
Telerik team
Share this question
or