I'm storing some data in my Cell.Tag which I need to access to in the converter. in the converter I can get the CellValuePresenter but I can't find a way to access to it's parent Cell. Is there anyway to do this?
<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="MyStyle">
<Setter Property="Background"
Value="{Binding RelativeSource={RelativeSource Self},Converter={StaticResource con}}">
</Setter>
</Style>
Thanks
Hello ashkank82,
Thank you for contacting us.
I have been looking into your issue and what I can suggest is to set the Tag property of the CellValuePresenter instead of the Cell. You can use the
FromCell method of the CellValuePresenter to get the CellValuePresenter and assign the Tag property.
More about this method you can find on the following link from our documentation: http://help.infragistics.com/Help/Doc/WPF/2015.2/CLR4.0/html/InfragisticsWPF4.DataPresenter.v15.2~Infragistics.Windows.DataPresenter.CellValuePresenter~FromCell.html.
Please do not hesitate to let me know if you have any further questions on this matter.
Hi Gergana,
Thanks for the reply. at the point when I'm setting these tag informations the CellValuePresenter is not constructed yet and it always returns NULL. I tried setting the virtualization for cells to false as well but unfortunately that also doesn't work. Is there anyway to access the Cell from converter/CellValuePresenter ?
I have been looking into your question and have created a small sample application for you.
In the sample application I have used the style you have provided in your initial post. Then for the Value of the Background I create a MultiBinding, where I bind to the Field and the Record properties for the CellValuePresenter. I also have a MultiValueConverter. In this converter I get the Cell from the corresponding Field and Record using the following:
Cell c = (values[1] as DataRecord).Cells[(values[0] as Field).Name] as Cell;
Please find the attached sample application and feel free to let me know if you have any further questions on this matter.
Hi,
This is working perfectly fine. Thank you very much. However when I change the values in the cells (edit cell values) the tag is being recalculated. But the colour for my cells doesn't change. Would you please show me how can I trigger the styling again when the cell values are changed?
I have been looking into your question and have modified the sample application, that I have provided in my previous post.
In the modified sample application I have set a key for the Style with the converter and created a new one without a key, that is based on the one with the key.
The style without a key would apply to the CellValuePresenters when the application starts.
Then in order to reapply the style when a cell is changed I handle the EditModeEnded event and get the CellValuePresenter, from the changed cell and apply the style with the key.
This way the converter fires again and apply the changes to the Background of the cell.
Please find the modified sample application attached and feel free to let me know if you have any further questions on this matter.
It's working fine. Thanks.
I just had to create a new style every time that the value was being changed based on the existing style because otherwise the second edit will not affect.
cvp.Style = new Style(typeof(CellValuePresenter), dataGrid_MainRequirement.Resources["tagStyle"] as Style);
I am glad you have found a solution to your issue. Please do not hesitate to let me know if you have any further questions on this matter.