Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Wiring up commands
Message
From
08/05/2009 03:37:20
 
 
To
07/05/2009 14:25:18
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01398201
Message ID:
01398539
Views:
43
>>Am I missing something simple?
>>
>>I had a form where I wired up some of the ready-built commands in the forms CommandBindings and implemented the CanExecute and Executed methods.
>>
>>A canvas class creates a context menu and assigns commands to MenuItems.
>>All working fine.
>>
>>Now I've created a UserControl which contains the canvas and moved all the command related logic to it rather than the form but now the ICommand methods don't fire. Top of my head I can't see why there should be a difference but it's knocking off time and the pub beckons. Any suggestions as to the cause are welcome....
>>
>>TIA,
>>Viv
>
>Where are your Focus scopes set? (I know we had a long discussion of this a while back. So maybe I'm not getting the problem.)
>
>If your menu is in the same focus scope as the form the commands are just traveling back up the path to the menu item.
>
>I think the wording I came up with was that the command travels the path to the item with keyboard focus in the focus scope of the form.
>

Hi,
Thx. I'm going to have to take some time and review this event routing stuff in depth :-{
I've got this working by setting the CommandTarget for each MenuItem to the object that triggered the menu construction.
For buttons on the form I set the CommandTarget to the UserControl instance.
When the Items in the UserControl were just embedded directly into the form these weren't needed (but I did need a .Focus() in the form constructor)
Best,
Viv
Previous
Reply
Map
View

Click here to load this message in the networking platform