0

我是 MVVM 世界的新手,我有一个 XAMl

<UserControl x:Class="KeyDownMVVM.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="186,125,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
    </Grid>
</UserControl>

我想处理 userlcontrol keydown 事件来捕捉键盘修饰符和键,但使用 MVVM 模式有任何想法。我使用银光 4 。大部分教程都讲具体的控制

4

1 回答 1

1

我建议查看MVVMLight框架中的“EventToCommand”。它将允许您指定一个在您的视图模型上调用命令的事件。有很多关于如何在 SO 或其他地方使用它的例子。

于 2012-10-31T18:05:13.433 回答