![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | 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) |
| | 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) |
| | 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 | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| the problem with ndis.sys Blue Screen of Death problem solved? | Vista General | |||
| Re: Windows Mail Attachement Problem and Adobe Player Problem with IE8 | Vista mail | |||
| Generic McAfee Problem Message in Vista Problem Reports | Vista performance & maintenance | |||
| fixed unable to delete email problem, now I have new problem | Vista mail | |||
| Vista Upgrade Problem - Windows Explorer Loop problem | Vista installation & setup | |||