h1

Hello,

Setup:

In my app, I have a MenuItem (mi) and I¡¯ve hooked up a Command (cmd) to it.

My app has a main window (win). The window has a frame (frm) that I use to navigate to page (pg1).

In win.ctro I add a commandbinding for cmd. When I go to menu item and select the mi, the cmd fires.

In pg1.ctor I have another commandbinding for cmd.

Problem:

When frm navigates to pg1, and I select the mi, the win.cmd fires not the pg1.cmd.

My findings so far:

a) I think this has to do with the CommandTarget setting. But I don¡¯t seem to be able to give keyboard focus to the pg1 after it is loaded. Is ther a way I can do this

b) I put a button btn on pg1 and set the btn.Command to the same binding as the mi. When I click the button, I get the pg1.cmd behavior. THEN if I click the mi I get the pg1.cmd behavior. So I thought if I set btn.IsDefault=true, I¡¯ll somehow signal that it is the page that has focus. But it doesn¡¯t work that way. I have to click the button and then pg1.cmd gets linked up to the mi.

Thanks in advance.



Re: Windows Presentation Foundation (WPF) MenuItem.Command - multiple binding

Yi-Lun Luo - MSFT

Excuse me, can you paste some code