![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Problem with 'CommandBinding' and 'PreviewExecuted' Hi, Has anybody encountered a problem such as this one: In a Window, I declare a command binding to the 'copy' command... In the command binding declaration, I map a function to the 'PreviewExecuted' routed event and to the 'Executed' routed event. The XAML looks as follows: <Window.CommandBindings> <CommandBinding Command="ApplicationCommands.Copy" Executed="HandlerCopyExecute" PreviewExecuted="HandlerCopyPreviewExecute" /> </Window.CommandBindings> My problem is that whenever I map an Handler to the "PreviewExecuted" event, then I won't receive the "Executed" event.... If I remove the handler to the "PreviewExecuted" event, then the "Executed" event is called. I did not find any indication in the SDK documentation indicating that a particular action is required in the "PreviewExecuted" handler in order to allow the "Executed" to occur! I am using the February CTP, and I'm starting to wonder if this is a bug in the WPF Thanks |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Problem with 'CommandBinding' and 'PreviewExecuted' It seems that Microsoft deliberately prevents us from having PreviewExecuted and Exectued events fired simultaneously, here is the evidence: internal void OnExecuted(object sender, ExecutedRoutedEventArgs e) { if (!e.Handled) { if (e.RoutedEvent == CommandManager.ExecutedEvent) { if ((this.Executed == null) || !this.CheckCanExecute(sender, e)) { return; } this.Executed(sender, e); e.Handled = true; } else if ((this.PreviewExecuted != null) && this.CheckCanExecute(sender, e)) { this.PreviewExecuted(sender, e); e.Handled = true; } } } This method is a part of implementation of CommandBinding class.Sheva "Marcus" <larochem@gmail.com> wrote in message news:1141392914.254252.14250@i39g2000cwa.googlegroups.com... > Hi, > > Has anybody encountered a problem such as this one: > > In a Window, I declare a command binding to the 'copy' command... In > the command binding declaration, I map a function to the > 'PreviewExecuted' routed event and to the 'Executed' routed event. > > The XAML looks as follows: > > <Window.CommandBindings> > <CommandBinding > Command="ApplicationCommands.Copy" > Executed="HandlerCopyExecute" > PreviewExecuted="HandlerCopyPreviewExecute" > /> > </Window.CommandBindings> > > My problem is that whenever I map an Handler to the "PreviewExecuted" > event, then I won't receive the "Executed" event.... > > If I remove the handler to the "PreviewExecuted" event, then the > "Executed" event is called. > > I did not find any indication in the SDK documentation indicating that > a particular action is required in the "PreviewExecuted" handler in > order to allow the "Executed" to occur! > > I am using the February CTP, and I'm starting to wonder if this is a > bug in the WPF > > Thanks > |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Problem with 'CommandBinding' and 'PreviewExecuted' After this answer from Sheva, I took a deeper look at the code and realized the following... The "PreviewExecuted" in the CommandBinding is completelly useless... >From what I see, the CommandBinding object only registers to the "Executed" RoutedEvent of the Command... Meaning that the "tunneling" effect expected from the "PreviewExecuted" would not occur, it is simply the same thing as the the "Executed"... Why would Microsoft put a "Preview" executed in the CommandBinding then? More than that, even if it can be "easilly" deduced, the events originating from the "CommandBinding" are not routed at all, they are plain old .NET events... I originally had some confusion about routing of the command events because of it... The code snippet from Sheva illustrate that behavior really well... Thanks a lot... Sheva wrote: > It seems that Microsoft deliberately prevents us from having PreviewExecuted > and Exectued events fired simultaneously, here is the evidence: > internal void OnExecuted(object sender, ExecutedRoutedEventArgs e) > { > if (!e.Handled) > { > if (e.RoutedEvent == CommandManager.ExecutedEvent) > { > if ((this.Executed == null) || > !this.CheckCanExecute(sender, e)) > { > return; > } > this.Executed(sender, e); > e.Handled = true; > } > else if ((this.PreviewExecuted != null) && > this.CheckCanExecute(sender, e)) > { > this.PreviewExecuted(sender, e); > e.Handled = true; > } > } > } > This method is a part of implementation of CommandBinding class.Sheva > > "Marcus" <larochem@gmail.com> wrote in message > news:1141392914.254252.14250@i39g2000cwa.googlegroups.com... > > Hi, > > > > Has anybody encountered a problem such as this one: > > > > In a Window, I declare a command binding to the 'copy' command... In > > the command binding declaration, I map a function to the > > 'PreviewExecuted' routed event and to the 'Executed' routed event. > > > > The XAML looks as follows: > > > > <Window.CommandBindings> > > <CommandBinding > > Command="ApplicationCommands.Copy" > > Executed="HandlerCopyExecute" > > PreviewExecuted="HandlerCopyPreviewExecute" > > /> > > </Window.CommandBindings> > > > > My problem is that whenever I map an Handler to the "PreviewExecuted" > > event, then I won't receive the "Executed" event.... > > > > If I remove the handler to the "PreviewExecuted" event, then the > > "Executed" event is called. > > > > I did not find any indication in the SDK documentation indicating that > > a particular action is required in the "PreviewExecuted" handler in > > order to allow the "Executed" to occur! > > > > I am using the February CTP, and I'm starting to wonder if this is a > > bug in the WPF > > > > Thanks > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Multi-select problem in Windows Explorer BIG PROBLEM!!!!!! | Jim Hansen | Vista General | 3 | 12-16-2007 08:09 PM |
| Generic McAfee Problem Message in Vista Problem Reports | cyberbuff53 | Vista performance & maintenance | 0 | 12-01-2007 07:55 AM |
| fixed unable to delete email problem, now I have new problem | j2 | Vista mail | 19 | 03-29-2007 08:25 PM |
| audio problem with my sony vaio laptop and x64 problem | =?Utf-8?B?YWxleA==?= | Vista hardware & devices | 1 | 07-14-2006 09:32 AM |
| Vista Upgrade Problem - Windows Explorer Loop problem | Steve S | Vista installation & setup | 0 | 06-27-2006 10:15 AM |