Reputation: 135
I'm using the material design in XAML library and my TextBoxes are acting strange. When you type something into them, the KeyboardFocus is not set on the TextBox, so the keybindings don't work. When you click the TextBox it has focus and the keybindings work, but as soon you start typing something, you lose focus and and must re-click the TextBox to get focus back.
<TextBox
materialDesign:HintAssist.Hint="Type something..."
Style="{DynamicResource MaterialDesignFloatingHintTextBox}"
Text="{Binding Name}"> <!--this binding works-->
<TextBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding SearchCommand}"/>
</TextBox.InputBindings>
</TextBox>
Upvotes: 0
Views: 125
Reputation: 135
I found the solution to my Problem. It was not a focus problem, instead nothing happened, because the updatesourcetrigger was set to lostfocus by default, so when you press enter in my Application nothing would happen, because you still had the same Entry(Binding Name) as before and it would be ignored. So the solution was setting it like this.
Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}"
Upvotes: 1