views:

247

answers:

0

In Silverlight 3, I'm using the Silverlight toolkit's DataGrid control with a RowDetailsTemplate.

In my template I've got some controls that will allow the user to edit the row. I want to set focus to the first control when the template is loaded for the row. I've got this working for the first row, but there seems to be a bug with setting focus - in that it hangs the application.

Here's my code:

private void dgReconcile_RowDetailsVisibilityChanged(object sender, DataGridRowDetailsEventArgs e)
{
    if (e.DetailsElement.Visibility == System.Windows.Visibility.Visible)
    {
        Debug.WriteLine("Finding datStarted");
        var control = e.DetailsElement.FindName("datStarted") as Control;

        if (control != null)
            control.Focus();
    }
}

This works fine for the first row in the grid, but it seems to hang the application on the call to control.Focus for any other row! Seems like a major bug to me.

It's all working fine if I don't try to set focus though, but it's a bit inconvenient for the user!