Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Using cell contents as the index value for a binding operation (DataGrid)

$
0
0


<DataGridTextColumn Header="Last Study" Binding="{Binding XPath=History/Assignment[1]/@Study}" IsReadOnly="True"><DataGridTextColumn.CellStyle><Style TargetType="DataGridCell"><Setter Property="ToolTip" Value="{Binding Source={StaticResource StudyPoints}, Path=[0].Title}" /></Style></DataGridTextColumn.CellStyle></DataGridTextColumn>

In the above XAML markup I am setting the cell ToolTip property to the value of the first index entry in a resource:

<Setter Property="ToolTip" Value="{Binding Source={StaticResource StudyPoints}, Path=[0].Title}" />

In the following XAML markup I use a different approach which displays the cell contents as the ToolTip:

<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self},Path=Content.Text}"/>

The markup:

<DataGridTextColumn Header="Last Study" Binding="{Binding XPath=History/Assignment[1]/@Study}" IsReadOnly="True"><DataGridTextColumn.CellStyle><Style TargetType="DataGridCell"><Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self},Path=Content.Text}"/></Style></DataGridTextColumn.CellStyle></DataGridTextColumn>

My problem is I want to combine the two.  I need something like:


IndexVariable = {Binding RelativeSource={RelativeSource Self},Path=Content.Text}<Setter Property="ToolTip" Value="{Binding Source={StaticResource StudyPoints}, Path=[IndexVariable].Title}" />



But I do not know how to do it.

Andrew


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>