我有一个ListView,它可以有一个上下文菜单.我正在分别使用registerForContextMenu和unregisterForContextMenu注册本身或与显示/工作的上下文菜单相关的任何问题.
为上下文菜单注册视图时,当用户单击它时,其背景会逐渐从橙色变为黄色,然后再变为白色.从未为上下文菜单注册视图(它保持相同的颜色)时,不会发生这种情况.但是,当我unregisterForContextMenu用来取消注册相关视图时,此效果仍然有效并且可能会使用户感到困惑 - 因为效果,他/她会期望一个上下文菜单.这说明unregisterForContextMenu并没有完全扭转效果registerForContextMenu.
我的问题是:有没有办法完全取消注册View获取上下文菜单?
如果有人更清楚地知道(un)registerForContextMenu内部如何运作,请分享您的想法.
编辑:我刚看到这不适用于HTC的感知界面,因为没有实现'美白'效果.所以这个问题仅适用于默认的Android界面.
我想用C++添加一个上下文菜单项.我一直在寻找,但我能找到的只是一些傻瓜试图向我推销一些BS程序,它为我做了这不是我想要的.我也不是在寻找任何使用.NET或Visual C++的东西.我想要直接的C++方式来做到这一点.
我将在Python GTK窗口(pyGTK)中禁用右键单击(以及上下文菜单),其中内部位于"窗口"pyWebKitGtk.
有人可以帮我写一些代码吗?
我认为最好直接在pyGTK中删除事件,但如果你知道如何在pyWebKitGtk中显示上下文菜单仍然是好的.
TNK TNK TNK
真的削减代码:
import gtk
import webkit
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.connect("destroy", gtk.main_quit)
browser = webkit.WebView()
browser.open("http://www.stackoverflow.com")
scroller = gtk.ScrolledWindow()
scroller.add(browser)
window.add(scroller)
window.show_all()
gtk.main()
Run Code Online (Sandbox Code Playgroud) 我有一个用户控件,资源如下:
<UserControl.Resources>
<Image x:Key="IconPrinter" Source="/PrintViewerWPF;component/Resources/Images/printer.png" />
<MenuItem x:Key="PrintDoc"
Header="Print"
Click="PrintDoc_OnClick"
Icon="{StaticResource IconPrinter}" />
<ContextMenu x:Key="MergedContextMenu">
<StaticResource ResourceKey="PrintDoc"/>
</ContextMenu>
<ContextMenu x:Key="SingleContextMenu">
<StaticResource ResourceKey="PrintDoc"/>
</ContextMenu>
<DataTemplate x:Key="mergedDocDisplayGrid">
<StackPanel StackPanel.ContextMenu="{DynamicResource MergedContextMenu}" />
</DataTemplate>
<DataTemplate x:Key="singleDocDisplayGrid">
<StackPanel StackPanel.ContextMenu="{DynamicResource SingleContextMenu}" />
</DataTemplate>
</UserControl.Resources>
Run Code Online (Sandbox Code Playgroud)
所述DataTemplates的一个的DevExpress内使用FlowLayoutControl
在我的场景中,我有两个项目FlowLayoutControl.一个使用模板mergedDocDisplayGrid,另一个使用singleDocDisplayGrid
数据在模板中正确显示,并且已成功实现其他功能,如鼠标活动和拖放
在任一项上显示上下文菜单都有效,但如果我随后尝试再次在另一项上显示上下文菜单,则会出现以下异常:
Message - Add value to collection of type 'System.Windows.Controls.ItemCollection' threw an exception.
Inner - Element already has a logical parent. It must be detached from the old parent before it …Run Code Online (Sandbox Code Playgroud) 我有一个treeView,其itemsource是我的Model类的集合.我在treeView上添加了一个上下文菜单.由于contextMenu的命令应该在可视树中,所以我不得不将它们放在我的Model类中.哪个错误(将模型绑定到目录).
如何将我的上下文菜单的命令绑定到我的ViewModel而不是Model?
谢谢
我知道如何使用chrome中的chrome扩展在上下文菜单中制作单选按钮.但我得到的是如何将它们分组.因此,某些无线电元素作为一个集合起作用,并且只能选择其中一个.但这样做不会影响其他集合(组)中的元素.
在上下文菜单中创建项目时,您所要定义的只是它的id,类型,父级和其他变得更加无关紧要的东西.
我非常感谢你的帮助.谢谢.
我正在阅读的示例代码位于:http: //developer.chrome.com/extensions/examples/api/contextMenus/event_page/sample.js
上下文菜单的Api参考:http://developer.chrome.com/extensions/contextMenus.html#method-create
我真的需要一些帮助.我正在尝试将一个我认为32bpp的图像加载到MenuItem上的预乘alpha (我按照本指南在GIMP中制作图像).我知道ContextMenuStrip类,不想使用它.
以下是我用于将图像设置到MenuItem上的代码:
// apis
[DllImport("user32.dll", SetLastError = true)]
static extern bool SetMenuItemInfo(IntPtr hMenu, uint uItem, bool fByPosition,
[In] ref MENUITEMINFO lpmii);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern IntPtr LoadImage(IntPtr hinst, string lpszName, uint uType,
int cxDesired, int cyDesired, uint fuLoad);
// structures
[StructLayout(LayoutKind.Sequential)]
struct MENUITEMINFO
{
public uint cbSize;
public uint fMask;
public uint fType;
public uint fState;
public uint wID;
public IntPtr hSubMenu;
public IntPtr hbmpChecked;
public IntPtr hbmpUnchecked;
public IntPtr …Run Code Online (Sandbox Code Playgroud) 我有上下文菜单的datagrid.它以编程方式初始化:
contextMenu = new ContextMenu();
foreach (var col in this.Columns)
{
var checkBox = new MenuItem()
{
Header = col.Header
};
Binding myBinding = new Binding("Visibility");
myBinding.Mode = BindingMode.TwoWay;
myBinding.Converter = new IsCheckedToVisibilityConverter();
checkBox.DataContext = col;
checkBox.SetBinding(MenuItem.IsCheckedProperty, myBinding);
checkBox.Click += checkBox_Click;
checkBox.Checked += checkBox_Checked;
checkBox.Unchecked += checkBox_Unchecked;
contextMenu.Items.Add(checkBox);
}
Run Code Online (Sandbox Code Playgroud)
它工作得很好,但我想在检查\取消选中菜单项后保持打开上下文菜单.有任何想法吗 ?
我有一个ListView控件,以网格布局显示文件夹内的文件。我有一个上下文菜单,其中有三个Items应具有以下功能:
ListView上下文菜单中的文件,将显示其所有3ItemsListView第一个中的空白区域,则Item应该不可见。这是我想补充我的事件,并为代码MouseClick我的事件ListView:
this.listviewFiles.MouseClick += new System.Windows.Forms.MouseEventHandler(this.listViewFiles_MouseClick);
private void listViewFiles_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
if (listviewFiles.FocusedItem.Bounds.Contains(e.Location) == true)
{
contextMenuFilesListbox.Items[0].Visible = false;
contextMenuFilesListbox.Items[1].Visible = false;
}
else
{
contextMenuFilesListbox.Items[0].Visible = true;
contextMenuFilesListbox.Items[1].Visible = true;
}
contextMenuFilesListbox.Show(Cursor.Position);
}
}
Run Code Online (Sandbox Code Playgroud)
发生的事情是,当我右键单击listViewFiles_MouseClick事件中的空白区域时,根本不会触发。因此,我无法Item在上下文菜单中恢复不可见的内容。