【发布时间】:2014-09-24 06:45:31
【问题描述】:
我有一个文本框,并且为它绑定了 ctrl 键。假设用户在文本框中输入了以下句子。
"I love my Country "
并且当前光标位置在单词“Country”内。现在用户只需按下 control(ctrl) 键,然后我希望将光标位置下表示“国家”的当前单词传递给我的视图模型。
<TextBox x:Name="textBox" Width="300" Text="{Binding SomeText, UpdateSourceTrigger=PropertyChanged}">
<TextBox.InputBindings>
<KeyBinding Key="LeftCtrl" Command="{Binding LeftCtrlKeyPressed, Mode=TwoWay}" CommandParameter="" />
</TextBox.InputBindings>
</TextBox>
有没有办法通过命令参数传递当前单词。
【问题讨论】:
-
CommandParameter不允许依赖属性。 -
好的。在这种情况下,我还有其他选择来实现目标吗?