views:

19

answers:

1

In SL4 DataGrid I have the following multicontrol column:

<sdk:DataGridTemplateColumn Header="Address Line1&#x0a;Address Line 2" MinWidth="200">
  <sdk:DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
      <StackPanel>
        <TextBlock Text="{Binding Path=Address1}"/>
        <TextBlock Text="{Binding Path=Address2}"/>
      </StackPanel>
    </DataTemplate>
  </sdk:DataGridTemplateColumn.CellTemplate>
  <sdk:DataGridTemplateColumn.CellEditingTemplate>
    <DataTemplate>
      <StackPanel>
        <TextBox Background="Transparent" BorderThickness="0" 
                 TabIndex="0"
                 Text="{Binding Path=Address1, Mode=TwoWay}"/>
        <TextBox Background="Transparent" BorderThickness="0" 
                 TabIndex="1"
                 Text="{Binding Path=Address2, Mode=TwoWay}"/>
      </StackPanel>
    </DataTemplate>
  </sdk:DataGridTemplateColumn.CellEditingTemplate>
</sdk:DataGridTemplateColumn>

In edit mode pressing Tab key while at address1 moves focus to next DataGrid column but not to address2 textbox. If I delete CellTemplate and CellEditingTemplate to be CellTemplate instead, then TabIndex works as expected, however, current column stay the same, so if datagrid has many columns, some of which are hidden, then auto scrolling doesn't occur. What should I do to solve this problem?

A: 

Probably, having multiple controls inside datagrid cell is bad idea. If multiple controls needs to be inside cell, then better way seems to be to create custom composite control and place it inside cell.

synergetic