首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >根据其他ListcollectionView的当前项更新ListCollectionView

根据其他ListcollectionView的当前项更新ListCollectionView
EN

Stack Overflow用户
提问于 2015-06-26 17:02:14
回答 1查看 346关注 0票数 0

我想在每次选择另一个ListCollectionView的项目时更新列表框中的ListCollection。

我有两个ListViewCollection,SceneCollectionView和ShotCollectionView。我希望根据ShotCollectionView中的属性SceneNumber过滤SceneCollection,但在SceneCollectionView中,当我从一个项目转到另一个项目时,我可以获得要更新的ShotCollectionView。

这是我的ViewModel

代码语言:javascript
复制
public class ShotListViewModel : NotifyUIBase
{
    public ListCollectionView SceneCollectionView { get; set; }
    private Scenes CurrentScene
    {
        get { return SceneCollectionView.CurrentItem as Scenes; }
        set { SceneCollectionView.MoveCurrentTo(value); RaisePropertyChanged(); }
    }

    private ObservableCollection<Shot> _allShots = new ObservableCollection<Shot>();
    public ObservableCollection<Shot> AllShots
    {
        get { return _allShots; }
        set { _allShots = value; RaisePropertyChanged();}
    }

    private ListCollectionView _allShotsCollection;
    public ListCollectionView AllShotsCollection
    {
        get
        {
            if (_allShotsCollection == null)
            {
                _allShotsCollection = new ListCollectionView(this.AllShots);
                _allShotsCollection.Filter = IsSceneNumber;
            }
            return _allShotsCollection;
        }
    }

    private bool IsSceneNumber(object obj)
    {         
        if (obj as Shot != null
           && (obj as Shot).SceneNumber == (SceneCollectionView.CurrentItem as Scene).SceneNumber)
        {
            return true;                
        }
        return false;
    }


    public ShotListViewModel()
    {
        SceneCollectionView = Application.Current.Resources["SceneCollectionView"] as ListCollectionView;
        GetShotList(); //Populates the AllShots Observable collection.

        AddShotCommand = new RelayCommand(AddShot);
        FilterShotsCommand = new RelayCommand(AddShot);
    }

为了让它工作,我在这里遗漏了什么,还是使用ICollectionViewLiveShaping更好。但是我不知道如何实现它

EN

回答 1

Stack Overflow用户

发布于 2015-06-26 19:35:44

我不明白你想做什么,但让我们举一个例子:

让我们假设我们有

绑定到ListBox1ItemsListBox1和绑定到ListBox2

如果要过滤ListBox2中的数据,则必须过滤ListBox2Items.如何做到这一点?很简单:您可以绑定到-假设- ListBox1SelectedItem. - ListBox1有一个属性SelectedItem每次选择更改时,在ListBox1SelectedItem的设置器中,您都可以在ListBox2Items.上触发一个过滤器

希望你能理解我所解释的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31069051

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档