contextmenu

Get owner of context menu in code

徘徊边缘 提交于 2020-02-11 05:25:49
问题 I have a ContextMenu like this: <StackPanel Orientation="Horizontal"> <StackPanel.ContextMenu> <ContextMenu> <MenuItem Header="Delete" Click="OnDeleteClicked" /> </ContextMenu> </StackPanel.ContextMenu> </StackPanel> And I need to get the instance of the StackPanel that owns that ContextMenu . I already tried this: private void OnDeleteClicked(object sender, System.Windows.RoutedEventArgs e) { FrameworkElement parent = e.OriginalSource as FrameworkElement; while (!(parent is StackPanel)) {

Get the point of click on a control

て烟熏妆下的殇ゞ 提交于 2020-02-04 05:10:08
问题 I am using an old ActiveX control in my C# Win App. it has a MouseUp event that its eventArgs is passing the X and Y of the point that we have clicked but for my scenario I am using its ItemClick event and its eventArgs does not have the info about X and Y. but I need to know them to show my pop-up... so is there a way I can find out what is the location of X and Y that user has right-clicked so I can pass it to my contextMenuStrip.Show method. Thanks 回答1: The Control class has a static

Right-click on a NSStatusItem

半城伤御伤魂 提交于 2020-02-03 11:01:50
问题 I have a NSStatusItem and I want to popup a menu by rightclicking the item. I subclassed a NSView and overwrote the - (void)rightMouseDown:(NSEvent *)event method. I also implemented - (void)mouseDown:(NSEvent *)event for looking at the modifierflags. My problem is, that the view does not recieve the NSRightMouseDown -Event. And I don't know why? Any ideas how to get this event? Naturally I added the custom view to the statusitem. - UPDATE - Additional information: I have added a NSImageView

WPF ContextMenu Design. How to set Background in WPF MenuItem?

▼魔方 西西 提交于 2020-02-02 13:21:07
问题 I create popup menu like this. <DockPanel.ContextMenu> <ContextMenu Background="#CD252220" Opacity="0.95" Foreground="LightGray" BorderBrush="DarkGray"> <MenuItem Header="_Save Image..." x:Name="btSave" IsEnabled="False" Click="btSave_Click" Style="{StaticResource MyStyle}"> <MenuItem.Icon> <Image Source="icons/save.png" Width="16" Height="16" Style="{StaticResource IconStyle}"/> </MenuItem.Icon> </MenuItem> </ContextMenu> </DockPanel.ContextMenu> Why left-side of this menu is WHITE????? It

WPF ContextMenu Design. How to set Background in WPF MenuItem?

不想你离开。 提交于 2020-02-02 13:19:28
问题 I create popup menu like this. <DockPanel.ContextMenu> <ContextMenu Background="#CD252220" Opacity="0.95" Foreground="LightGray" BorderBrush="DarkGray"> <MenuItem Header="_Save Image..." x:Name="btSave" IsEnabled="False" Click="btSave_Click" Style="{StaticResource MyStyle}"> <MenuItem.Icon> <Image Source="icons/save.png" Width="16" Height="16" Style="{StaticResource IconStyle}"/> </MenuItem.Icon> </MenuItem> </ContextMenu> </DockPanel.ContextMenu> Why left-side of this menu is WHITE????? It

Need Windows command file that runs all commands in a folder [closed]

▼魔方 西西 提交于 2020-01-30 03:26:06
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 months ago . https://www.online-tech-tips.com/computer-tips/create-windows-batch-files/ explains how to create a command (batch) file that opens a set of specific Windows commands. I'd like to generalize this, so I can create folders that contain command shortcuts and run such a folder (using

Dynamic ContextMenu In CodeBehind

我们两清 提交于 2020-01-22 13:38:26
问题 I just want to add ContextMenu for several objects that I create dynamically, but The only way I found is to create ContextMenu in runtime like this: ContextMenu pMenu = new ContextMenu(); MenuItem item1 = new MenuItem(); MenuItem item2 = new MenuItem(); //I have about 10 items //... item1.Header = "item1"; item1.Click += new RoutedEventHandler(item1_Click); pMenu.Items.Add(item1); item2.Header = "item2"; item2.Click += new RoutedEventHandler(item2_Click); pMenu.Items.Add(item2); //and so on

Best way to set a MenuItem's sub-menu height?

不打扰是莪最后的温柔 提交于 2020-01-21 22:19:06
问题 I currently have a menuitem (part of a context menu), with about ~35 menu items. Because of this, it causes the sub-menu to be huge. Even though I have scrolling ability, I would like to set the height of this submenu while having the ability to still scroll. I've messed w/ the MenuItem.Itemspanel but have not been able to set the sub-menu's height and still scroll. 回答1: Unfortunately, WPF does not allow this to be modified by properties. You will have to modify the default ControlTemplate.

add menu item to default context menu

眉间皱痕 提交于 2020-01-20 03:26:27
问题 I'd like to add a menu item to the default ContextMenu of a RichTextBox . I could create a new context menu but then I lose the spell check suggestions that show up in the default menu. Is there a way to add an item without re-implementing everything? 回答1: It's not too tricky to reimplement the RichTextBox context menu with spelling suggestions, Cut, Paste, etc. Hook up the context menu opening event as follows: AddHandler(RichTextBox.ContextMenuOpeningEvent, new ContextMenuEventHandler

add menu item to default context menu

試著忘記壹切 提交于 2020-01-20 03:26:26
问题 I'd like to add a menu item to the default ContextMenu of a RichTextBox . I could create a new context menu but then I lose the spell check suggestions that show up in the default menu. Is there a way to add an item without re-implementing everything? 回答1: It's not too tricky to reimplement the RichTextBox context menu with spelling suggestions, Cut, Paste, etc. Hook up the context menu opening event as follows: AddHandler(RichTextBox.ContextMenuOpeningEvent, new ContextMenuEventHandler