WPF(XAML, XBAP, .Net ..
[2ch|▼Menu]
752:デフォルトの名無しさん
10/05/01 10:52:45
2010を使い.NET4でWPFを始めてみました
ググりながら試行錯誤してコマンドとコンテキストメニューを繋ごうとしています
キー操作だと正常に動作し、PlayPause_Executeが呼ばれるのですが、
コンテキストメニューは見出しやキーの表示は合っていますが、グレー表示のままで選択できません
何が悪いのでしょうか?

タイマで定期的にCommandManager.InvalidateRequerySuggested();してみても変わらないようですし
キーを押したときにはCheckCanExecuteCommandが呼ばれますが、それ以外では呼ばれないようです

public class Commands
{
public static RoutedUICommand PlayPause = new RoutedUICommand("再生/一時停止", "PlayPause", typeof(Commands),
new InputGestureCollection { new KeyGesture(Key.Space) });
}

XAMLで(はしょっています)
<Window xmlns:local="clr-namespace:hoge">
<StatusBar.ContextMenu>
<ContextMenu>
<MenuItem Command="{x:Static local:Commands.PlayPause}" IsEnabled="True" />
</ContextMenu>
</StatusBar.ContextMenu>

C#側コンストラクタで
CommandBindings.Add(new CommandBinding(Commands.PlayPause, PlayPause_Execute, CheckCanExecuteCommand));

private void CheckCanExecuteCommand(Object sender, CanExecuteRoutedEventArgs e) {
e.CanExecute = true;
}



次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

5356日前に更新/192 KB
担当:undef