首页 新闻 会员 周边

怎么才能禁用ListBox右键选取功能?!

0
悬赏园豆:30 [已关闭问题] 关闭于 2008-08-01 13:13
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <DIV class=cnblogs_code><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ListBox&nbsp;</SPAN><SPAN style="COLOR: #ff0000">Height</SPAN><SPAN style="COLOR: #0000ff">="128"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;Width</SPAN><SPAN style="COLOR: #0000ff">="128"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;SelectionMode</SPAN><SPAN style="COLOR: #0000ff">="Extended"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ListBox.ContextMenu</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ContextMenu</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">MenuItem&nbsp;</SPAN><SPAN style="COLOR: #ff0000">Name</SPAN><SPAN style="COLOR: #0000ff">="cmi2"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;Header</SPAN><SPAN style="COLOR: #0000ff">="删除所有选中的文件"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">MenuItem&nbsp;</SPAN><SPAN style="COLOR: #ff0000">Name</SPAN><SPAN style="COLOR: #0000ff">="cmi3"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;Header</SPAN><SPAN style="COLOR: #0000ff">="清空文件列表"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">ContextMenu</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">ListBox.ContextMenu</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ListBoxItem</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">111111111111</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">ListBoxItem</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ListBoxItem</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">2222222222</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">ListBoxItem</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ListBoxItem</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">3333333333</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">ListBoxItem</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ListBoxItem</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">44444444444444</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">ListBoxItem</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ListBoxItem</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">5555555555</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">ListBoxItem</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">ListBox</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV> <DIV class=cnblogs_code><SPAN style="COLOR: #0000ff">&nbsp;</SPAN></DIV> <DIV class=cnblogs_code><SPAN style="COLOR: #0000ff"> <P align=left>如上代码,这是一个可多选的ListBox,并拥有一个右键上下文菜单。</P> <P align=left>WPF里让ListBox支持通过右键选取或取消选取项。</P> <P align=left>现在的问题是,我点右键的时候会显示出右键菜单,并且同时改变了我鼠标所在位置的项的选择状态。</P> <P align=left>比如我想挑选3项,然后通过菜单将其删除,但是用右键打开菜单时就会改变我的选择状态,比如取消了一个已选择的项。</P> <P align=left>怎么才能禁用右键选取功能?</P> <P align=left>或者什么方法才能拦截ListBoxItem的右键点击事件?</P></SPAN></DIV>
斯克迪亚的主页 斯克迪亚 | 老鸟四级 | 园豆:4124
提问于:2008-07-31 17:10
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册