Reputation: 681
Is it possible to use FocusAction to move focus to another control from a KeyBehavior? If so, an example would be helpful. TIA
Upvotes: 1
Views: 136
Reputation: 31831
Fascinating.
This is what does NOT work:
<TextBox x:Name="T1">
<Interactivity:Interaction.Behaviors>
<b:KeyBehavior Key="Enter">
<b:FocusAction TargetObject="{Binding ElementName=T2}" />
</b:KeyBehavior>
</Interactivity:Interaction.Behaviors>
</TextBox>
<TextBox x:Name="T2" />
But I love the idea and I will add it to the behavior soon.
In the meanwhile, there is no declarative way to do it without a custom something you create. BTW, I tried this (also does NOT work):
<TextBox x:Name="T1">
<Interactivity:Interaction.Behaviors>
<b:KeyBehavior Key="Enter">
<Core:CallMethodAction MethodName="Focus" TargetObject="{Binding ElementName=T2}" />
</b:KeyBehavior>
</Interactivity:Interaction.Behaviors>
</TextBox>
<TextBox x:Name="T2" />
Does not work because Focus has parameters and the behavior does not support passing parameters. Though I wish it would.
Great idea though. Sort of like forcing TAB, huh? Cool.
Jerry
Upvotes: 0