Search Results

Search found 2 results on 1 pages for 'ikhail'.

Page 1/1 | 1 

  • WPF: Can't get to original source from ExecutedRoutedEventArgs

    - by Ikhail
    I have a problem getting to the original source of a command using ExecutedRoutedEventArgs. I'm creating a simple splitbutton, in which a menu will appear below a dedicated button, as another button is pressed. When I click a menuitem in the appearing menu a command is fired. This command is registered on the splitbutton. And the idea is to get to the menuitem beeing clicked, by using the ExecutedRoutedEventsArgs. Ok, now the problem. If I choose to have the popup menu shown by default (IsOpen="True") and I click one of the menuitems I can get to the originalsource (thus the menuitem) from the ExecutedRoutedEventArgs - no problem. However, if I first click the button to show the menu and THEN click on a menuitem, the originalsource of the command will be the button instead of the MenuItem! Here's the controltemplate for the splitbutton: <ControlTemplate TargetType="{x:Type usc:SplitButton}"> <StackPanel Orientation="Horizontal"> <Button Name="mybutton"> <StackPanel> <Popup usc:SplitButton.IsPopup="True" IsOpen="True" Name="myPopup" PlacementTarget="{Binding ElementName=mybutton}" StaysOpen="False" Placement="Bottom"> <Border BorderBrush="Beige" BorderThickness="1"> <Menu Width="120"> <MenuItem Header="item1" Command="usc:SplitButton.MenuItemClickCommand" /> <MenuItem Header="item2" /> <MenuItem Header="item3" /> </Menu> </Border> </Popup> <TextBlock Text="MySplitbutton" /> </StackPanel> </Button> <Button Content="OK" Command="usc:SplitButton.ShowMenuCommand" /> </StackPanel> </ControlTemplate> The OK button fires a ShowMenuCommand on the SplitButton, which sets the IsOpen property on the Popup to True. Any ideas why the OK button (after having activated the menu) is the OriginalSource when a menuitem is clicked? Thanks.

    Read the article

  • WPF: Implementation of ApplicationCommands.Copy?

    - by Ikhail
    I just created a menu with Command="ApplicationCommands.Copy" and I thought I had to handle the Executed event of the binding, and add a binding but I just don't need to. Now I'm confused! Where is the implementation of this command? How can it automatically copy a text selected in any of the textboxes I have in my window? thanks!

    Read the article

1