Ok, I have an unusual scenario here, one of my users requested an autocomplete style combobox column. I have pieced together one from some examples I have found online. Unfortunately for me this is all smoke and mirrors and I ended up with an autocomplete box on top of a combo box databound to the same source. When the cell is activated I would like the autocomplete box to enter edit mode. I have tried to use the VisualTreeHelper to traverse the cell control when the activecellchanging event is fired to no avail. Any suggestions?
MARKUP:
<igGrid:TemplateColumn HeaderTex<igGrid:TemplateColumn HeaderText="Absence Code" Key="ABSValue"> <igGrid:TemplateColumn.ItemTemplate><DataTemplate><TextBlock Text="{Binding ABSValue}"/></DataTemplate></igGrid:TemplateColumn.ItemTemplate><igGrid:TemplateColumn.EditorTemplate><DataTemplate><Grid IsHitTestVisible="True" Grid.Column="1" Grid.Row="1" Grid.RowSpan="1"><ComboBox IsTabStop="False" x:Name="AbsCombo" HorizontalAlignment="Left" Width="100" SelectionChanged="AbsCombo_SelectionChanged"ItemsSource="{Binding Source={StaticResource AbsRecords}}"DisplayMemberPath="AbsCode"></ComboBox><input:AutoCompleteBox TabIndex="2" IsTabStop="True" x:Name="AbsCompleteBox" HorizontalAlignment="Left" Width="80"ItemsSource="{Binding Source={StaticResource AbsRecords}}"ValueMemberPath="AbsCode" TextChanged="AbsCompleteBox_TextChanged"><input:AutoCompleteBox.ItemTemplate><DataTemplate><TextBlock Text="{Binding AbsCode, Mode=TwoWay}"/></DataTemplate></input:AutoCompleteBox.ItemTemplate></input:AutoCompleteBox></Grid></DataTemplate></igGrid:TemplateColumn.EditorTemplate></igGrid:TemplateColumn>
Close, not quite there. You see the AutoCompleteBox column is not the first in the list, and I am using row as the edit mode for editing settings, you can imagine the issue this would cause. You did however give me another good idea so thanks for the assist.
private void OccurrenceGrid_ActiveCellChanging(object sender, Infragistics.Silverlight.ActiveCellChangingEventArgs e){ if (e.NewActiveCell.Column.Key == "ABSValue") { AddNewRowCellControl nrc = e.NewActiveCell.Control as AddNewRowCellControl; AutoCompleteBox AutoBox = ((nrc.Content as Grid).Children[1] as AutoCompleteBox); (VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(AutoBox, 0), 0) as TextBox).Focus(); }}
Hi,
One way to achieve this, is to add an EventListener to the Loaded event of your AutoCompleteBox. Then in the Eventhandler, set focus to the control.
-SteveZ