Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
450
Display Initial Cell Value in a Tooltip
posted

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:

  • DataValueChangedNotificationsActive="True"
  • DataValueChangedHistoryLimit="2"
  • CellValuePresenterStyle="{StaticResource CellStyles}"

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!

Parents Reply Children