相关文章推荐

Like sorting, filtering in a CollectionViewSource is not automatically done when you change the contents of one of the data bound items.  By default, you need to call the Refresh method of the CollectionViewSource .

In the example below, we filter on first name “Joan” and then change Joan Fontaine’s first name to “Bob”.  Notice that the list is not re-filtered–Bob remains in the list.

You can fix this by adding the FirstName property to the LiveFilteringProperties collection of the CollectionViewSource and setting IsLiveFilteringRequested to true .

<CollectionViewSource x:Key="cvsActors" Source="{Binding ActorList}" IsLiveFilteringRequested="True"> <CollectionViewSource.LiveFilteringProperties> <clr:String>FirstName</clr:String> </CollectionViewSource.LiveFilteringProperties> <CollectionViewSource.SortDescriptions> <scm:SortDescription PropertyName="LastName" /> </CollectionViewSource.SortDescriptions> </CollectionViewSource>

Now, when we change Joan to Bob and we’re filtering on “Joan”, Bob automatically disappears from the list.

what xmlns should be added to the heading of xaml to get the below accepted:
FirstName

Reply
Feb »

Blog Stats

  • 5,383,332 hits
  • Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
    To find out more, including how to control cookies, see here: Cookie Policy
 
推荐文章