I'm in the process of giving automation IDs to individual cells within a WPF datagrid, but I've hit a bit of a snag. I've decided to try naming the cells according to their position in the grid (row index and column index). Using a UI inspector and highlighting one of the DataGridCells in question shows the following properties:
GridItem.Row: 2
GridItem.Column: 0
... which leads me to believe that I can access these properties via binding. However, I've spent the better part of the last few days combing the Internet for how to go about this, but haven't found anything.
The current XAML code is as follows (the '???' are placeholders):
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="AutomationProperties.AutomationId">
<Setter.Value>
<MultiBinding StringFormat="cell:{0}-{1}">
<Binding ??? />
<Binding ??? />
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
</DataGrid.CellStyle>
Does such a path to these properties exist? Or does another method exist for giving unique automation IDs to individual cells? I'm not very experienced with WPF and XAML so any pointers are appreciated.
Thanks in advance.