How to reset RowStyle to default?

5 posts, 0 answers
  1. Markus
    Markus avatar
    12 posts
    Member since:
    Nov 2013

    Posted 28 May 2014 Link to this post

    In my GridView I color rows differently based on the current value of a Combobox column. Each change of the combobox value triggers the PropertyChanged event of the business object.
    This works just fine as long as I return one of my own styles in SelectStyle. The row gets correctly drawn using that style.
    The problem is, that I want to reset the row style to default (= no style) for one particular combobox value. In this case SelectStyle returns base.SelectStyle(item, container) which is always null (= OK). But the row remains drawn using the previous style although the PropertyChanged event is correctly triggered. If I force the UI to recreate the UI controls of that row (by manually resizing the window), the row is drawn correctly.

    What am I missing?

    Can I force a redraw of that row to remove the previous style other than by triggering the PropertyChanged event?
    I could create my own "Empty Style", but this is what I want to avoid. Any ideas?

    Thanks for any help.

    Markus
  2. Yoan
    Admin
    Yoan avatar
    1213 posts

    Posted 30 May 2014 Link to this post

    Hi Markus,

    Actually, this is know issue. It has been logged in our bug tracking system for further investigation.

    Regards,
    Yoan
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. Markus
    Markus avatar
    12 posts
    Member since:
    Nov 2013

    Posted 02 Jun 2014 in reply to Yoan Link to this post

    Hi Yoan,

    thanks for your note.
    Once you investigated this issue, can you please let me know if there is a workaround possible or in which release of Telerik for WPF his is going to be fixed.

    Thanks and best regards,
    Markus
  4. Yoan
    Admin
    Yoan avatar
    1213 posts

    Posted 02 Jun 2014 Link to this post

    Hi Markus,

    The problem has been logged into our Feedback portal as bug report. You can track the status of the issue by following the feedback item: Row's style is not updated when the SelectStyle method of RowStyleSelector returns null. Once we have a progress we will change its status.

    The only workaround that I can suggest is to return some "fake" style targeting GridViewRow. For example:
    public class StadiumCapacityStyle : StyleSelector
       {
           public override Style SelectStyle(object item, DependencyObject container)
           {
               if (item is Club)
               {
                   Club club = item as Club;
                   if (club.StadiumCapacity > 50000)
                   {
                       return BigStadiumStyle;
                   }
               }
               //return null;
               return TempStyle;
           }
     
     
           public Style BigStadiumStyle { get; set; }
     
           public Style TempStyle { get; set; }
       }
     
    <my:StadiumCapacityStyle x:Key="stadiumCapacityStyle">
               <my:StadiumCapacityStyle.BigStadiumStyle>
                   <Style TargetType="telerik:GridViewRow">
                       <Setter Property="Background" Value="Red"/>
                   </Style>
               </my:StadiumCapacityStyle.BigStadiumStyle>
               <my:StadiumCapacityStyle.TempStyle>
                   <Style TargetType="telerik:GridViewRow">
                       <Setter Property="MaxHeight"  Value="100"/>
                   </Style>
               </my:StadiumCapacityStyle.TempStyle>
           </my:StadiumCapacityStyle>

    I hope this helps.


    Regards,
    Yoan
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  5. Markus
    Markus avatar
    12 posts
    Member since:
    Nov 2013

    Posted 03 Jun 2014 Link to this post

    Thanks Yoan!

    I go with the "fake" style for now.

    Best regards,
    Markus
Back to Top