I have an app where users will enter lists of names. (There is some collection of valid names.) I'm not sure what the most user-friendly way to do this is.
One idea: Make a text box. If the text box loses focus, and the contents are a valid name, add it to a list box. If the user selects an entry in the list box and hits delete, remove it.
The code:
MainPage.xaml.cs:
private void WhoOwesInput_LostFocus(object sender, RoutedEventArgs e)
{
if (people.Contains(WhoOwesInput.Text))
{
WhoOwesListBox.Items.Add(WhoOwesInput.Text);
WhoOwesInput.Text = String.Empty;
}
}
private void WhoOwesListBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Delete || e.Key == Key.Back)
{
WhoOwesListBox.Items.Remove(WhoOwesListBox.SelectedItem);
}
}
MainPage.xaml:
<sdk:AutoCompleteBox Height="23" HorizontalAlignment="Left" Margin="337,205,0,0" Name="WhoOwesInput" VerticalAlignment="Top" Width="74" ValueMemberBinding="{Binding}" LostFocus="WhoOwesInput_LostFocus" />
<ListBox Height="100" HorizontalAlignment="Left" Margin="337,232,0,0" Name="WhoOwesListBox" VerticalAlignment="Top" Width="74" KeyDown="WhoOwesListBox_KeyDown" />
I'm new to SL, so I'm afraid I may be missing out on some controls or preferred way of doing things. Any advice?
Thanks.