See the question and my original answer on StackOverflow

Here is how you can do it:

        // get to ROW X (here it's row #1 name is always "Row X")
        AutomationElement row1 = dataGrid.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "Row 1"));

        // get row header
        AutomationElement row1Header = row1.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Header));

        // invoke it (select the whole line)
        ((InvokePattern)row1Header.GetCurrentPattern(InvokePattern.Pattern)).Invoke();

To find these operations, you can use UISpy and try the different items in the tree, look at the pattern each item implements and try them out using the UISpy contextual "Control Patterns" menu.