I wish to focus a specific Textbox
and accept the key press only when the user presses a number key (1,2,3 etc.) otherwise I don't want to focus that Textbox
...
Senario:
I have ListView
(having a custom view) in a view. below the list view i have a Textbox
.
Lets say ListView
contains items numbered as 1, 2, 3, 33, 373 etc.
Now when I press a number key, lets say Key 3
, the following action should occur:
- Focus that Specific
TextBox
- Append the
TextBox
text with the number input - Select the item in the
ListView
with the same number asTextBox.Text
has
My Xaml for what I tried
<ListView Name="lv"
Grid.Row="1"
ItemsSource="{Binding}"
View="{Binding Path=SelectedItem,
ElementName=viewComboBox}" DisplayMemberPath="Name" IsTextSearchEnabled="True" TextSearch.TextPath="{Binding Path=Person.Name}"/>
<TextBox Grid.Row="2" Text="{Binding Path=TextSearch.Text,ElementName=lv}"></TextBox>
Nothing is displayed in the TextBox
and I don't know how to handle numeric key press.
I need this and its bewildering using MVVM...
Any help in this regard would be great. And some guidance using code would be even better... Thanks...