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

How to reset RowStyle to default?

4 Answers 193 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Markus
Top achievements
Rank 1
Markus asked on 28 May 2014, 12:22 PM
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

4 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 30 May 2014, 06:38 PM
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.
 
0
Markus
Top achievements
Rank 1
answered on 02 Jun 2014, 11:44 AM
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
0
Yoan
Telerik team
answered on 02 Jun 2014, 04:49 PM
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.
 
0
Markus
Top achievements
Rank 1
answered on 03 Jun 2014, 07:51 AM
Thanks Yoan!

I go with the "fake" style for now.

Best regards,
Markus
Tags
GridView
Asked by
Markus
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Markus
Top achievements
Rank 1
Share this question
or