Binding 带过滤的Silverlight绑定

Binding 带过滤的Silverlight绑定,binding,silverlight-4.0,filtering,Binding,Silverlight 4.0,Filtering,我目前正试图在Silverlight4中找到一个绑定解决方案 我有一个可观察到的项目集合。我想将其绑定到组合框,但只显示符合特定条件的项。例如,group==测试组。我已经尝试了很多方法来实现这一点,但都没有成功 过去,我在VM上的一个公开属性中使用了LINQ,例如: /// <summary> /// Get filtered results(by location) /// </summary> public ObservableCol

我目前正试图在Silverlight4中找到一个绑定解决方案


我有一个可观察到的项目集合。我想将其绑定到组合框,但只显示符合特定条件的项。例如,group==测试组。我已经尝试了很多方法来实现这一点,但都没有成功

过去,我在VM上的一个公开属性中使用了LINQ,例如:

    /// <summary>
    /// Get filtered results(by location)
    /// </summary>
    public ObservableCollection<SearchResultData> FilteredResults        {
        get
        {
            return new ObservableCollection<SearchResultData>(Results.Where(p => p.LocationId == CurrentLocation.Id));
        }
    }
使用此方法,当LINQ中的基础集合发生更改时,您需要提供通知,例如:

    public ObservableCollection<SearchResultData> Results
    {
        get { return _results; }
        set
        {
            _results = value;
            NotifyOfPropertyChange(() => Results);
            NotifyOfPropertyChange(() => FilteredResults);
        }
    } 

你认为哪种方式最有可能奏效?包括您尝试的代码?