I have a TextBox and DropDown inside a ListView that is bound to a viewModel. Although comboBox is working fine, I cannot "enter" text inside a TextBox. Backspace / SpaceBar / Ctrl + C / Ctrl + V work fine, but as soon as I press any alphanumeric key, it does not show text in the TextBox.
Also checked using an empty KeyUp / KeyDown / TextChange event handler. It raises the KeyUp / KeyDown event for all types of keystrokes, but TextChange does not fire when any alphanumeric key is pressed.
Please suggest anyone ever come across this problem. Or if there is a way to debug and find the actual problem.
This is my XAML - nothing in the code is behind.
<Window x:Class="Ion.MarketView.Mmi.Plugins.AlertConfigurator.View.AlertConditionItemViewDebug" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" x:Name="aletConditionItems" mc:Ignorable="d" > <Grid > <Grid.Resources> <Style TargetType="ListViewItem"> <Setter Property="HorizontalContentAlignment" Value="Stretch" /> <Setter Property="VerticalContentAlignment" Value="Stretch" /> </Style> </Grid.Resources> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"></ColumnDefinition> <ColumnDefinition Width="75"></ColumnDefinition> </Grid.ColumnDefinitions> <ListView Grid.Column="0" x:Name="lstViewConditionItems" ItemsSource="{Binding ElementName=aletConditionItems, Path=DataContext.Items}" SelectedItem="{Binding ElementName=aletConditionItems, Path=DataContext.SelectedItem, Mode=TwoWay}"> <ListView.View> <GridView> <GridViewColumn Header="Column Id" > <GridViewColumn.CellTemplate> <DataTemplate> <ComboBox SelectedValue="{Binding Path=ColumnId}" Margin="-6,-2,-6,-2" ItemsSource="{Binding ElementName=aletConditionItems, Path=DataContext.ColumnIds}" /> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Header="Value" Width="100" > <GridViewColumn.CellTemplate> <DataTemplate> <TextBox Text="Only backSpace and SpaceBar works" ></TextBox> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> </ListView> <StackPanel Orientation="Horizontal" Grid.Column="1" VerticalAlignment="Top" > <Button Content="+" Width="30" Command="{Binding ElementName=aletConditionItems, Path=DataContext.OnAddConditionItem}"></Button> </StackPanel> </Grid> </Window>
Thank you for your interest.
Note: 1) I am loading this WPF window from a WinForm application.
2) The problem is NOT in binding a textBox with viewModel. I canβt even edit plain text that is hardcoded in the Text property (as in the code above)
3) I have not registered a βnoβ event handler in any parent control.
Solution: According to the links suggested by @HCL, the following code fixed my problem.
Window window1 = new Window(); ElementHost.EnableModelessKeyboardInterop(window1); //This is needed for Sharing Message Loops Between Win32 and WPF window1.Show();