1

我想知道是否有人可以解释为什么我不能使用IsKeyboardFocusWithinChangedwith EventTrigger

 <StackPanel>
    <TextBox >
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="IsKeyboardFocusWithinChanged">
                <i:InvokeCommandAction Command="{Binding Path=SomeCommand}"/>
            </i:EventTrigger>
        </i:Interaction.Triggers>
    </TextBox>
    <Button Content="Click Me" />
</StackPanel>

public partial class MainWindow : Window
{
    public ICommand SomeCommand { get; set; }
    public MainWindow()
    {
        InitializeComponent();
        SomeCommand = new SampleCommand();
        DataContext = this;
    }
}

public class SampleCommand : ICommand
{
    public void Execute(object parameter) { MessageBox.Show("Bingo"); }
    public bool CanExecute(object parameter) { return true; }
    public event EventHandler CanExecuteChanged;
}

在上述代码中连接其他事件按预期工作,IsKeyboardFocusWithinChanged在后面的代码中连接也是如此。

4

0 回答 0