contextmenu

Command binding not working in a dynamic MVVM Context Menu

纵然是瞬间 提交于 2019-12-09 20:24:44
问题 I am new to WPF. Like many others, I am trying to bind a ContextMenu to an ObservableCollection to create a dynamic context menu. Everything works except binding the Command property to the TheCommand property of the MenuItemViewModel class, that represents the menu item. The command is not fired. What am I doing wrong? To start from the beginning, the ContextMenu is a child of the Image and is shown when the mouse is over the Image . <Image.ContextMenu > <ContextMenu ItemsSource="

onCreateContextMenu isn't being called

十年热恋 提交于 2019-12-09 18:18:45
问题 It looks like the onCreateContextMenu insn't being called at all. In my onCreate for my ListActivity I have: list = getListView(); registerForContextMenu(list); (I know it's redundant, and I've just passed getListView() with the same results). Here is my onCreateOntextMenu; @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); Log.d("LM", "onCreateContextMenu"); MenuInflater inflater = getMenuInflater();

Show ContextMenu on Left Click using only XAML

浪子不回头ぞ 提交于 2019-12-09 17:26:01
问题 The default behavior of a WPF ContextMenu is to display it when the user right-clicks. I want the ContextMenu to show when the user left-clicks. It seems like this should be a simple property on ContextMenu , but it is not. I rigged it, so that I handle the LeftMouseButtonDown event in the code-behind and then display the context menu. I'm using MVVM in my project which means I'm using DataTemplate s for the items that have the context menus. It would be much more elegant to get rid of the

Bind ContextMenu's MenuItem visibility to ListView selection

心不动则不痛 提交于 2019-12-09 17:10:34
问题 I have a user control with a ListView containing simple items from an ObservableCollection. I would like the ContextMenu of that ListView to contain items depending on what's selected in the ListView. If no item is selected, some MenuItems should not be visible. My converter isn't even called when I open the ContextMenu. The binding seems to be wrong, I find this in the output window: System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=listView'.

Using MVVM, how can a ContextMenu ViewModel find the ViewModel that opened the ContextMenu?

混江龙づ霸主 提交于 2019-12-09 16:45:22
问题 I'm using MVVM to bind views to objects in a Tree. I have a base class that implements the items in my tree, and that base class has a ContextMenu property: public IEnumerable<IMenuItem> ContextMenu { get { return m_ContextMenu; } protected set { if (m_ContextMenu != value) { m_ContextMenu = value; NotifyPropertyChanged(m_ContextMenuArgs); } } } private IEnumerable<IMenuItem> m_ContextMenu = null; static readonly PropertyChangedEventArgs m_ContextMenuArgs = NotifyPropertyChangedHelper

How to add custom item on Global long press Contextmenu like Translate and Wikipedia

穿精又带淫゛_ 提交于 2019-12-09 14:00:12
问题 I want to know how google translate and wikipedia app did to add their item on the webview long press context menu. P.S. This screenshot is from Nexus 5 6.0.1 version. 回答1: They added an activity that supports ACTION_PROCESS_TEXT via an <intent-filter> : <intent-filter > <action android:name="android.intent.action.PROCESS_TEXT"/> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" /> </intent-filter> On the Intent delivered to the activity (obtained

C# - DatagridView and ContextMenu

纵然是瞬间 提交于 2019-12-09 10:58:38
问题 I have a datagridview where I show infomation about products. I want to bind a contextmenu when the user selects a cell and then right clicks on that cell. I have another contextmenu and that one is bound to the columns of the datagridview. If a user right clicks on a column the contextmenu shows. I have tried like this but it does not work. The context menu shows when the user right clicks on a cell, but the contextmenu that is bound to the column header does not work. private void GridView1

“Build” item in Windows Explorer's context menu of a VS solution file?

▼魔方 西西 提交于 2019-12-09 09:35:40
问题 I wonder why this is not integrated by default. I'd like to have an item in Windows Explorer's file context menu of a VS solution file to build it. Is there a tool for this? Or do I have to create this myself? 回答1: MSBuild Shell Extension have been there for years, http://msbuildshellex.codeplex.com/ But you might also try out my new project, http://msbuildlaunchpad.codeplex.com/releases/view/45368 It is quite easy to use. MSBuild Launch Pad http://i3.codeplex.com/Project/Download

menu inflating calls multiple times at fragment's onCreateOptionsMenu

限于喜欢 提交于 2019-12-09 08:17:28
问题 I use Fragments and when I switch to nested Fragment, which implements public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) my menu inflates quantity of times when I get to that nested Fragment. How can I avoid this? I also implement constructor of Fragment with methods: setRetainInstance(true); setHasOptionsMenu(true); When I tried to implement siple solution as: @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // TODO Add your menu entries here if(

NSWindow - Right click menu

自作多情 提交于 2019-12-09 06:52:49
问题 Is there any way to show a menu when a NSWindow is right-clicked? 回答1: Rightclick on a view in the window and you will find a property called "menu". Connect this menu property with the menu which should be shown after a right click. 回答2: Yes. NSWindow inherits from NSResponder , which has handy methods like -rightMouseDown:. edit Actually a better way to do it might be to use a custom NSView subclass for the window's contentView , and override -menuForEvent: (a method on NSView ) to return