I have a TextBox and a DropDown inside a ListView which is binded to a viewModel. While comboBox is working fine, i am not able to "enter" any text inside the TextBox. Backspace/SpaceBar/Ctrl+C/Ctrl+V are working just fine, but as soon as i press any alphanumeric key, it doesn;t shows any text in the TextBox.
Have also checked using empty KeyUp/KeyDown/TextChange event handler. It raises KeyUp/KeyDown event for all type of key press but TextChange is not triggered on pressing any alphanumeric key.
Please suggest if anyone has faced this problem ever. Or if there is a way to debug and find the actual problem.
This is my XAML - nothing in code 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>
Thanks for your interest.
Note: 1) I am loading this WPF window from a WinForm application.
2) The problem is NOT in the binding of textBox with viewModel. I am not even able to edit a simple text that is hardcoded in the Text property (as in the code above)
3) I have not registered "any" event handler in any parent control.
Solution: As per 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();