I am using a templated column for editing. i have multiple text boxes in a Grid in the EditorTemplate.
I am trying so set Focus when going in to edit mode using:
Private Sub dgPO_CellEnteredEditMode(ByVal sender As Object, _ ByVal e As Infragistics.Silverlight.EditingCellEventArgs) Handles dgPO.CellEnteredEditMode
If e.Cell.Column.Key = "Notes" Then
Dim grd As Grid = e.Editor
Dim tb As TextBox = grd.Children(0) 'used to be 1 before change tb.Focus() End If
is there any reason this shouldnt work? am i doing something wrong?? is it possible?
Hi,
So, a control can only be focused after its been loaded. In the CellEnteredEdit mode, the content of the cell hasn't finished loading, which is why if you check the returned value of the Focus() method, you'd see that it returned false.
However, you can simply solve the problem, by hooking into the loaded event of the control you want to have focus:
<ig:TemplateColumn.EditorTemplate>
<DataTemplate>
<StackPanel>
<TextBox Loaded="TextBox_Loaded" Text="{Binding Title, Mode=TwoWay}"></TextBox>
<TextBox Text="{Binding Type, Mode=TwoWay}"></TextBox>
</StackPanel>
</DataTemplate>
</ig:TemplateColumn.EditorTemplate>
private void TextBox_Loaded(object sender, RoutedEventArgs e)
{
((Control)sender).Focus();
}
-SteveZ
For same xaml (Template Columns with StackPanel & textBox), I need to move to next row when Enter Key is pressed.
How can I achieve this?
Thanks,
Shakti
that works great, thanks. i should have thought of that