Hey Guys,
I have a couple of editable cells in my XamDataGrid (Infragistics 14, .Net 4.0, Windows 7) and I'd like to display the initial values of these cells in tooltips - displayed when you hover over any of the editable cells. I tried doing this by adding a style like the following:
<Style x:Key="CellStyles" TargetType="{x:Type ig:CellValuePresenter}" BasedOn="{StaticResource {x:Type ig:CellValuePresenter}}" > <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsEditingAllowed}" Value="True"> <Setter Property="ToolTip"> <Setter.Value> <Label Content="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ig:CellValuePresenter}, Path=ValueHistory.Count}" ContentStringFormat="Original Value: {0}"/></Setter.Value></Setter> </DataTrigger></Style.Triggers> </Style>
This was more of a test to see if I can show the ValueHistory.Count in the tooltip next to some text but it looks like my binding's messed up; I receive the following error:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Infragistics.Windows.DataPresenter.CellValuePresenter', AncestorLevel='1''. BindingExpression:Path=ValueHistory.Count; DataItem=null; target element is 'Label' (Name=''); target property is 'Content' (type 'Object')
Any suggestions on the above?
In regards to my actual usecase, I'm having trouble accessing the initial value from the ValueHistory. I set the three properties below as follows:
But I can't access the original value from the ValueHistory list in my xaml. Any ideas? Is there a better way to go about doing this? I considered binding a property to the tool tip value but I need the style to work for any editable cell on any grid that uses this style. Thanks in advance for your help!
Hello Amilcar,
Thank you for your feedback.
Please let me know if you need any further assistance on the matter.
Thanks for the insight; I decided to keep my approach as it is working fine. I was just wondering if there's a better more standard way to do it.
I am just checking your progress on the issue that you are having.
If you require any further assistance please do not hesitate to ask.
I have been investigating your question and contacting with our development team. DataValueChanged feature could be helpful in your scenario only if you know in advance that the number of changes that you will make, will be small, since the control keeps the last ‘n’ of number changes in memory. There is no reliable a way to set ‘n’ to a value that ensures the initial value will be preserved in the history and that the history will not grow to a point where memory consumption becomes an issue. If you only want only to tracking changes that the user makes via editing cells, another available approach is to use the Tag property of the Cell, so you could handle the EditModeStarted event. If the Tag property of the Cell is null then get the value and set it on the Tag property and bind your Tooltip to this Tag property.
?