Hi Guys, Sorry for the delay in getting back to you both,
Thanks Christian, I had a look at the ScrollViewer Control and it seems to only allow you to scroll to the first and last items automatically. There is ScrollViewer.ScrollToHorizontalOffset but you need to know the SelectedIndex of the item that you want to scroll to and knowing the SelectedIndex is half the problem.
I looked more into the TextSearch class and it seems a little promising. If you enable TextSearch and set the TextPath on the field you want to search, when you press a letter on the keyboard it selects the first item in the list with that letter. All that is needed now is to substitute the keyboard input with a button click.
TextSearch Example Code:
<Window.Resource>
<DataTemplate x:Key="listboxTemplate">
<TextBlock Text="{Binding Path=Name}"/>
</DataTemplate>
</Window.Resources>
<Grid>
<ListBox x:Name="listbox" ItemTemplate="{StaticResource listboxTemplate}"
IsTextSearchEnabled="True" TextSearch.TextPath="Name"/>
</Grid>
var query = from s in dc.People
orderby s.Name
select s;
listbox.ItemsSource = query.ToList();
I know its kind of crude but i have found a couple of samples of virtual keyboard simulation that might be a means to an end. The code below works for TextBox's but i haven't quite worked out how to adapt it to work with a ListBox.
void keyboardButton_Click(object sender, RoutedEventArgs e)
{
if (System.Windows.Input.Keyboard.FocusedElement.GetType() == typeof(TextBox))
{
TextBox box = ((TextBox)System.Windows.Input.Keyboard.FocusedElement);
int newIndex = box.CaretIndex + 1;
box.Text = box.Text.Insert(box.CaretIndex, ((Button)sender).Content.ToString());
box.CaretIndex = newIndex;
}
}
Thanks again for the replies, Ill yet you know if i make any progress,
Alex