XamDataGridのスタイルを作成して、ホバーされている現在のセルに基づいてツールチップに表示する値を決定できるようにしています。
私は以下を試しています:
<Style x:Key="MyCVPStyle" TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="ToolTip">
<Setter.Value>
<StackPanel>
<ListView ItemsSource="{Binding RelativeSource={...}, Path=Field, Converter={StaticResource MyFieldConverter}}">
...
スタイルのDataContextはDataRecordに設定されます。私が抱えている問題は、セル値プレゼンターの実際のフィールドにアクセスする方法がわからないことです。
ソースを次のように設定してみました:
{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:CellValuePresenter}}, Path=Field
しかし、それはバインディングエラーで失敗します:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Infragistics.Windows.DataPresenter.CellValuePresenter', AncestorLevel='1''. BindingExpression:Path=Field; DataItem=null; target element is 'ListView' (Name=''); target property is 'ItemsSource' (type 'IEnumerable')
CellValuePresenter.Fieldにアクセス/バインドして、その値をコンバーターに渡すにはどうすればよいですか?
参考までに、フィールドにアクセスする場所で問題なく機能する他のCellValuePresenterスタイルがあります。たとえば、ここで2番目のバインディングパラメータはフィールドであり、Selfを参照してアクセスします。
<Setter Property="BorderThickness">
<Setter.Value>
<MultiBinding Converter="{StaticResource BorderThicknessConverter}">
<MultiBinding.Bindings>
<Binding Path="DataItem" />
<Binding RelativeSource="{RelativeSource Self}" Path="Field" />
</MultiBinding.Bindings>
</MultiBinding>
</Setter.Value>
</Setter>