I'm in the process of providing automation IDs to individual cells in a datagrid WPF document, but I hit a bit. I decided to try to name the cells according to their position in the grid (row index and column index). Using the user interface inspector and selecting one of the DataGridCells in question, you will see the following properties:
GridItem.Row: 2 GridItem.Column: 0
... which makes me think that I can access these properties through binding. However, I have spent most of the past few days combing the Internet, how to do it, but have not found anything.
The current XAML code is as follows ("???" 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>
Is there such a way to these properties? Or is there another method for providing unique automation identifiers to individual cells? I am not very experienced with WPF and XAML, so any pointers are appreciated.
Thanks in advance.
source share