WPF - 仅使用 LeftClick 选择 ListBoxItem

发布于 2024-07-21 05:59:38 字数 84 浏览 1 评论 0原文

我有一个 SelectionMode="Multiple" 的列表框,它允许我通过单击鼠标左键或右键来选择多行。 如何限制仅通过单击鼠标左键进行选择?

I have a ListBox with SelectionMode="Multiple", which allows me to select multiple rows by clicking either the left or right mouse buttons.
How can I restrict the selection to occur from the LEFT mouse button click only?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离不开的别离 2024-07-28 05:59:38

我猜你必须编写自己的 ListBox(Item),重写

    protected override void OnPreviewMouseRightButtonDown(MouseButtonEventArgs e)
    {
        base.OnPreviewMouseRightButtonDown(e);
    }

    protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
    {
        base.OnMouseRightButtonDown(e);
    }

EventHandler 并在 xaml 中使用自定义 ListBox(Item)。 不要忘记调用 e.Handled = true; 您可能还可以使用更通用的鼠标事件处理程序之一,并检查是否单击了鼠标右键,然后调用 e.Handled。

I guess you have to write your own ListBox(Item), override the

    protected override void OnPreviewMouseRightButtonDown(MouseButtonEventArgs e)
    {
        base.OnPreviewMouseRightButtonDown(e);
    }

or

    protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
    {
        base.OnMouseRightButtonDown(e);
    }

EventHandler and use your custom ListBox(Item) in your xaml. Don't forget to call e.Handled = true; you probably can also use one of the more general mouse event handlers and check if the right mouse button has been clicked and then call e.Handled.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文