Row alternation gets broken by setting VerticalContentAlignment

5 posts, 0 answers
  1. Robert
    Robert avatar
    9 posts
    Member since:
    Nov 2013

    Posted 22 Jan 2014 Link to this post

    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?
  2. Robert
    Robert avatar
    9 posts
    Member since:
    Nov 2013

    Posted 22 Jan 2014 Link to this post

    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.
  3. DevCraft banner
  4. Hristo
    Admin
    Hristo avatar
    41 posts

    Posted 27 Jan 2014 Link to this post

    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 >>
  5. Robert
    Robert avatar
    9 posts
    Member since:
    Nov 2013

    Posted 27 Jan 2014 in reply to Hristo Link to this post

    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.

  6. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 29 Jan 2014 Link to this post

    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 >>
Back to Top
DevCraft banner