多选在不工作的ListView [英] MultiSelection not working in ListView

查看:100
本文介绍了多选在不工作的ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ListView多选有问题。

I have problem in ListView MultiSelection.

下面是我的code:

   private ICommand _excludeCurveCommand;


    public ICommand ExcludeCurveCommand
    {
        get
        {
            if (_excludeCurveCommand == null)
                _excludeCurveCommand = new DelegateCommand<object>(param => this.ExcludeCurveExecuted(param));

            return _excludeCurveCommand;
        }
    }

    /// <summary>
    /// Executed event for ContextMenu --> Remove click
    /// </summary>
    /// <param name="param">param is FolderItemViewModel bound as CommandParameter</param>
    private void ExcludeCurveExecuted(object param)
    {

        ICollection<object> curves = param as ICollection<object>;
        int count =  curves.Count;
    }



 < Button Content="Exclude" Command="{Binding ExcludeCurveCommand}" CommandParameter="{Binding SelectedItems,ElementName=lstView}" .../>

< ListView Name="lstView"  ItemsSource="{Binding MyList}" SelectionMode="Extended" ..../>

在这里,我使用的转变,由前四个项目中选择。但在ExcludeCurveExecuted方法我得到了一些随机数始终。什么是这个问题。

Here i used shift and selected from first four items. But in ExcludeCurveExecuted method i getting some random counts always. What is the issue in this.

编辑:
*我不wantto与IsSelected标志去视图模型

* I don't wantto go with IsSelected flag in ViewModel

推荐答案

要我看来,你必须有的ListView UI支持虚拟化,因为它默认启用。这意味着,的ListView 借鉴UI中可见的唯一项目。

To me it seems that you have have ListView UI virtualization enabled, as it enabled by default. That means, that ListView draws only items visible on UI.

下面是MSDN 链接

要确保是什么(你的情况一样选择)接口去恐怕你没有任何其他选项,然后

To be sure what is going on interface (like selection in your case) I'm afraid you don't have any other option then


  • 或禁用虚拟化的用户界面(不好)

  • or disable UI virtualization (not good)

或实施模型视图 IsSelected 标志

祝你好运。

这篇关于多选在不工作的ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆