Apologies for the vague title but I don't know what this behaviour is called.
This is another issue we've found converting our Silverlight App to WPF. The Silverlight doesn't exhibit this behaviour and the person who implemented this code has since left the company so I can't ask them any questions.
I have a pivot grid with different types of tenders for different stores. It shows the amount of each tender and the totals for each tender, each location and the grand total:
However when I select on the totals:
and then deselect the total this happens:
It multiplies the tender by the number of tenders and copies it into each tender. Each time I click it does the same again.
It's worse if I select the the grand total as it multiplies twice.
What do I need to turn off or override in the pivot grid to stop this happening?
Hello Chris,
Is this the behavior you are seeing with the sample project I sent you or in your application? I ask as in the sample project I sent you, I am unable to reproduce this behavior as the totals cells are firing the event and are not editable as a result.
If this is what you are seeing in your full application, I have to wonder if this behavior is a result of other events that you may be handling or perhaps a difference in the version of the assemblies we are using. It will be helpful if you can modify the sample project I sent you such that it reproduces the behavior you are seeing. Alternatively, if you have an isolated sample that reproduces this, I will gladly take a look.
Please let me know if you have any other questions or concerns on this matter.
Andrew,
Thank you for this. Unfortunately it doesn't work, I'm not getting the event fired when I click into one of the totals cells. It fires when I click on one of the normal cells so I can't see why it's not working.
Thank you for your updates on this matter.
The reason that the cursor is getting stuck when cancelling the CellEditing event is because this event fires when the cell is coming out of edit mode and as such, cancelling this event will keep the cursor inside. This event is generally used as more of a validation-related event than for catching when a cell enters edit mode.
I have been digging around for a cancellable event to prevent a particular cell from going into edit mode, but there does not actually appear to be one in this case. As such, I would instead recommend that you do this via a Style for PivotCellControl. In this style, you can hook the PreviewMouseDown event via an EventSetter and mark it handled if the corresponding Cell.DataColumn or Cell.DataRow IsTotal. This will prevent selection and editing of the total cells.
I am attaching a sample project to demonstrate the above. I hope this helps.
PivotGridPreventEditDemo.zip
I've managed to dig a bit deeper and it is our code that's copying these values. It's happening in the "CellEdited" event handler we've added to our subclass of the XamPivotGrid.
As I said above the Silverlight version didn't allow us to select the Totals cells so we didn't see this problem. This is the important part.
I need to stop the Totals cells being put into edit mode. How do I do this?
Thanks for the reply.
1. We're using version 20.1.20201.9
2. I'll look at creating an isolated sample but if you say it's not the default behaviour then I might not be able to get a reproducible case that easily as we do have application specific code and have more than likely changed the behaviour. In Silverlight the totals cells aren't selectable at all, whereas in WPF I can put the cell into some sort of edit mode - albeit read only as you can see from the second screenshot.
Is there any way I can prevent the totals cells being selected? This is the ideal solution to the problem.
As I mentioned I've inherited this code from someone I can't now contact. If this is something that's caused by something we're doing what events should I be looking for that fire when the totals cells are clicked?
I tried adding a CellEditing event handler and cancelling the edit if one of the totals cells was selected:
if (e.Cell.DataColumn.IsTotal || e.Cell.DataRow.IsTotal) { e.Cancel = true; }
but that just appeared to lock the cursor in the totals cell. I couldn't then click on any other cell in the grid.
Chris.