こんにちは 私はWPFのCommandBindingsに奇妙な問題があります。 オブジェクトのコンストラクタにCommandBindingsを追加します。コマンドバインディングはそのWPFアプリケーションのコマンドバインディングが機能しない
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));
実行する責任がありCoresponding機能がそのように見て
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;
}
のように見える問題は、コマンドのみ作品をカットしていることです。私は他のfunciotn(コピーまたは貼り付け)でブレークポイントを設定すると、ブレークポイントにヒットしないことを意味します。誰かが私が何をやっているのか教えてもらえますか?
コードがCopy_Enabled方法を取得していますか? – Dabblernl