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

Problem with GridView GridCell styles

8 Answers 210 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ChrisM
Top achievements
Rank 1
ChrisM asked on 04 May 2011, 11:08 AM
Hello.

We have a bug that's arisen with a couple of GridViews. In each row, we have a number of columns. One of these columns, let's call it Column X, has a CellStyle that contains a DataTrigger to start a storyboarded animation for a cell's colour based on it's contents. Clearly, this animation is only meant to occur on cells in this particular column, but unfortunately, when the GridView is scrolled horizontally, the colour animation begins to play on cells in other columns in the row. Output from Snoop seems to suggest that the defined CellStyle on Column X is being erroneously retained somewhere and used as a default style for cells in other columns as they are dynamically created and destroyed, or perhaps reused, during the scrolling. The fact that the animation only starts on other columns when Column X is scrolled out of view seems to support this.

I have attempted to fix it by setting normal CellStyles on all of our other columns, but this hasn't alleviated the problem.

Is this an issue that has been observed before? Is there a solution, or perhaps some more steps that I can take to try to fix it?

Thanks,
- Chris M.

8 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 04 May 2011, 11:49 AM
Hello Chris,

 

You can set the EnableRowVirtualization="False" which will force the animation to load and not reload anymore. Note that this might increase the initial load time of the grid. 


Let me know how this goes.


Best wishes,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
ChrisM
Top achievements
Rank 1
answered on 04 May 2011, 12:09 PM
Hi Vanya,

Thanks! A slight variation of your suggestion has worked (I set EnableColumnVirtualization to false, not EnableRowVirtualization :) ).

That should sort this issue for the time being and, hopefully, for the rest of the project. However, there is the potential for our GridViews to grow to have a very large number of columns, so we might need to re-enable column virtualization further down the line. As a low-priority side-question then, is there a fix for this issue which would avoid turning off a potentially useful optimization?

Thanks again,
- Chris M.
0
Vanya Pavlova
Telerik team
answered on 04 May 2011, 12:34 PM
Hello Chris,

 

Indeed when the virtualization is turned on the cells are being reused/recycled. 
May you please share with us how do you apply your cell's style? 
As a side note I will recommend you to use CellStyleSelectors, you may refer to the following blog post. 


All the best,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
ChrisM
Top achievements
Rank 1
answered on 04 May 2011, 06:45 PM
Hi Vanya,

I'll post more details on the Style information you asked for tomorrow, but this fix has caused a more serious issue to emerge. One of the GridViews now fails with an InvalidOperationException when it is created inside a UserControl docked in the main window. The exception contains the following error:

"Specified element is already the logical child of another element. Disconnect it first."

I have tracked this down to a column in the GridView that has an x:Static binding to a property on a singleton object for its IsVisible property. Columns in the other GridView use exactly the same binding, and work with no issue. I haven't yet been able to determine why this is occurring. It's mystifying. This is the stack trace:

\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Cells\GridViewHeaderCell.cs:line 1142<br>
   at System.Windows.FrameworkElement.ChangeLogicalParent(DependencyObject newParent)<br>
   at System.Windows.FrameworkElement.AddLogicalChild(Object child)<br>
   at System.Windows.Controls.ContentControl.OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)<br>
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)<br>
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)<br>
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)<br>
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)<br>
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)<br>
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)<br>
   at Telerik.Windows.Controls.GridView.GridViewHeaderCell.PrepareHeaderContent() in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Cells\GridViewHeaderCell.cs:line 384<br>
   at Telerik.Windows.Controls.GridView.GridViewHeaderCell.Prepare() in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Cells\GridViewHeaderCell.cs:line 1142<br>
   at Telerik.Windows.Controls.GridView.GridViewHeaderRow.PrepareCell(GridViewCellBase cellBase, GridViewColumn column) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Rows\GridViewHeaderRow.cs:line 242<br>
   at Telerik.Windows.Controls.GridView.GridViewCellsPanel.PrepareCell(GridViewCellBase cell, GridViewColumn column) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Virtualization\GridViewCellsPanel.cs:line 403<br>
   at Telerik.Windows.Controls.GridView.GridViewCellsPanel.AddNewCell(GridViewRowItem row, GridViewColumn column) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Virtualization\GridViewCellsPanel.MeasureOnDemand.cs:line 77<br>
   at Telerik.Windows.Controls.GridView.GridViewCellsPanel.EnsureCells() in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Virtualization\GridViewCellsPanel.MeasureOnDemand.cs:line 58<br>
   at Telerik.Windows.Controls.GridView.GridViewCellsPanel.UpdateNonVirtualizedCells() in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Virtualization\GridViewCellsPanel.MeasureOnDemand.cs:line 152<br>
   at Telerik.Windows.Controls.GridView.GridViewCellsPanel.MeasureOverride(Size availableSize) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Virtualization\GridViewCellsPanel.cs:line 301<br>
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)<br>
   at System.Windows.UIElement.Measure(Size availableSize)<br>
   at System.Windows.ContextLayoutManager.UpdateLayout()<br>
   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)<br>
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()<br>
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)<br>
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)<br>
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)<br>
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

As it all occurs in Telerik code, I can't get much information out. I'm attempting to replicate it in a new project. I will have to pick this up tomorrow, but perhaps there's something in what's above that can lead to a solution.

- Chris M.
0
Vanya Pavlova
Telerik team
answered on 04 May 2011, 06:59 PM
Hi Chris,

 

Can you post more info about the grid version  you used? We do have some issues related to the GridViewColumn's IsVisible property which were immediately fixed. You may try our latest internal build where such a behavior cannot be observed.


Please give it a try and let me know how it goes.

 

All the best,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
ChrisM
Top achievements
Rank 1
answered on 05 May 2011, 09:22 AM
Hi Vanya,

I'm using the following version: Telerik WPF VSExtensions 2011.01.315.0

From where can I download the latest internal build, please?

- Chris M.
0
Vanya Pavlova
Telerik team
answered on 05 May 2011, 09:25 AM
Hi Chris,

 

You may download latest internal builds from Your Account -> Your Products -> Latest Internal Builds, you may use the following link. 


Kind regards,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
ChrisM
Top achievements
Rank 1
answered on 05 May 2011, 10:38 AM
Hi Vanya,

That's worked - thanks very much. I've deferred the original fix until the next time we update the Telerik WPF VSExtensions package - we can live with the bug until then :)

Thanks again,
- Chris M.
Tags
GridView
Asked by
ChrisM
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
ChrisM
Top achievements
Rank 1
Share this question
or