Best way to uniquely name DataGrid Rows % Cells?
In order to support automated testing tools I need to x:Name al开发者_运维百科l controls (so that the tool can "pick it up" and observe its details).
The question is concerning DataGrid where the ItemSoure is bound to a property (in the ViewModel).
What is the best way to ensure all rows and all grid cells are uniquely named? A better question is: If a DataGrid is x:Named, will automated test tools be able to observe its rows and individual cells, even if the rows/cells are NOT x:Named themselves?
Option 1 (which id like to avoid) is the x:Name each row (on the row loading event, as well as all of its column cells).
Is there perhaps another option where all of these are x:named (uniquely) automatically?
Even better, perhaps all this is not even needed.
In case anybody is interested, i found the answer. Listen for the Row-loaded event. From there recursively traverse down the rows layout/control tree while naming valid controls (while ignoring any layout controls... Grid, StackPanel, Border).
精彩评论