【发布时间】:2016-06-21 14:21:25
【问题描述】:
我试图将这个(从旧应用程序)转换为 MVVM 模式,但我不知道该怎么做。
textBoxLoader.AddHandler(CommandManager.ExecutedEvent, new RoutedEventHandler(PasteFunction), true);
private void PasteFunction(object sender, RoutedEventArgs e)
{
if ((e as ExecutedRoutedEventArgs).Command == ApplicationCommands.Paste)
{
// verify that the textbox handled the paste command
textBoxLoader.IsEnabled = false;
List<string[]> MachineList = new List<string[]>();
List<string> list = new List<string>(Regex.Split(textBoxLoader.Text, Environment.NewLine));
}}
如何从 WPF 文本框 粘贴事件 重现这个和调用命令? 我可以成功绑定Enter Key事件,但是如何绑定Paste事件呢?
下面是关于我如何在新的 MVVM 中绑定 Icommand 的代码 sn-p(Enter Key listener)
<UserControl.InputBindings>
<KeyBinding Key="Enter" Command="{Binding ClickCommand}" CommandParameter="{Binding Text, ElementName=textBoxLoader}"/>
</UserControl.InputBindings>
【问题讨论】: