こんにちは、WPF の CommandBindings に奇妙な問題があります。オブジェクトのコンストラクターに CommandBindings を追加します。コマンドバインディングは次のようになります
CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy,Copy_Executed,Copy_Enabled));
CommandBindings.Add(new CommandBinding(ApplicationCommands.Cut,Cut_Executed,Cut_Enabled));
CommandBindings.Add(new CommandBinding(ApplicationCommands.Paste,Paste_Executed,Paste_Enabled));
実行を担当する対応する関数はそのように見えます
private void Paste_Enabled(object sender,CanExecuteRoutedEventArgs e)
{
e.CanExecute = selectionService != null && selectionService.CurrentSelection.Count > 0;
}
private void Paste_Executed(object sender, ExecutedRoutedEventArgs e)
{
if (GetSelected() != null)
Paste(true);
else
Paste(false);
}
private void Copy_Executed(object sender, ExecutedRoutedEventArgs e)
{
Copy();
}
private void Copy_Enabled(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = selectionService.CurrentSelection.OfType<DesignerItem>().Count() > 0;
}
#endregion
private void Cut_Executed(object sender, ExecutedRoutedEventArgs e)
{
Copy();
DeleteCurrentSelection(false);
}
private void Cut_Enabled(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = this.SelectionService.CurrentSelection.Count() > 0;
}
問題は、cut コマンドしか機能しないことです。つまり、他の機能 (コピーまたは貼り付け) にブレークポイントを設定すると、ブレークポイントにヒットしません。誰かが私が間違っていることを教えてもらえますか??