开发者

Can you selectively enable or disable 'FilterDescriptors' in silverlight 4?

In Silverlight with RIA services it is very easy to implement simple data filtering with 'FilterDescriptor' instances.

However I've got a case where I have several filters and I want to enable or disable them based on other filters.

It seems like a simple 'Enabled' property would make开发者_运维问答 this really easy - but there is none.

Is there a way to achieve this without just manually defining all the filters I need every time the relevant checkbox is checked. Perhaps a subclass? (I haven't had time to try this myself yet)


I am doing this by setting each one to -1 by default, and have the IgnoredValue="-1" in the FilterDescriptor. You can also use null or Nothing depending on your language your using. Ken


Sorting / Filtering / Grouping is really will be easy with using "RIA Services DataFilter Control for Silverlight". http://riadatafilter.codeplex.com/


Use a converter to return a specific value (e.g) 0 for null value or Nothing. Then use 0 as IgnoredValue


Ok, here is what I do. I reset the filter, then set them, you can loop thru them and set them to anything you like...

Private Sub AppPickerComboBox_SelectionChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs) Handles AppPickerComboBox.SelectionChanged
    For fd As Integer = AppTranDomainDataSource.FilterDescriptors.Count - 1 To 0 Step -1
        If AppTranDomainDataSource.FilterDescriptors(fd).PropertyPath = "Application_ID" Then
            AppTranDomainDataSource.FilterDescriptors.Remove(AppTranDomainDataSource.FilterDescriptors(fd))
        End If
    Next fd
    AppTranDomainDataSource.FilterDescriptors.Add(New FilterDescriptor With {.PropertyPath = "Application_ID", .Operator = FilterOperator.IsEqualTo, .Value = AppPickerComboBox.SelectedValue, .IgnoredValue = -1})
End Sub
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜