collectionviewsource

WPF multiple filters CollectionViewSource, first filter added works correctly, second filter added does not

萝らか妹 提交于 2020-02-27 09:05:53
问题 I have a ListView that is bounded to a CollectionViewSource. I followed this article (refered to by many) for multiple filtering: http://www.zagstudio.com/blog/456#.UG8r6E1lWLE I have two checkboxes set up for testing that do nothing but add a filter. Whenever I click on either one first, the filter is added to the CollectionViewSource and it works. Then when I click on the opposite checkbox, instead of the other filter being added to the CollectionViewSource and both filters working, my

WPF How to set a maximum amount of results from CollectionViewSource

时光怂恿深爱的人放手 提交于 2020-02-03 07:29:29
问题 I am trying to display a set of data using a DataTemplate in an ItemsControl , with the ItemsPanel set as a uniform grid of size 3 x 3. The ItemsSource of the ItemsControl is set to bind to a CollectionViewSource which filters the source collection based on a search term. This all works fine. The list I am binding to is of an arbitrary size, but I only want 9 results to be displayed, but I can't for the life of me work out how to either: a) limit the CollectionViewSource to output the first 9

Is it possible to use CollectionView with LongListSelector for grouping?

亡梦爱人 提交于 2020-01-15 06:26:10
问题 I am trying to use LongListSelector in conjunction with CollectionView. It seems like CollectionView has all the "stuff" needed, but when I connect the two, nothing happens. Here's what I have so far: In my control's ctor (the guy that contains the LLS), I construct the CollectionView: GroupDescription group = new PropertyGroupDescription("FullName", new FirstLetterConverter(true, true)); m_view.GroupDescriptions.Add(group); Then, whenever the relevant dependency property (the one that

How to add or remove an item from a CollectionViewSource?

故事扮演 提交于 2020-01-11 09:42:12
问题 I want to bind a datagrid.itemsource to a List with anonymous type,so i bind it to a collectionViewSource,but i need to add or remove an item to the list,but i don't know how? 回答1: CollectionView and CollectionViewSource are, as their name suggest, only views . You can only manipulate the original collection. You should use an ObservableCollection if you want the changes to be automatically reflected in your UI. I would advise against using anonymous types for data binding. But if you must -

How to add or remove an item from a CollectionViewSource?

拈花ヽ惹草 提交于 2020-01-11 09:41:08
问题 I want to bind a datagrid.itemsource to a List with anonymous type,so i bind it to a collectionViewSource,but i need to add or remove an item to the list,but i don't know how? 回答1: CollectionView and CollectionViewSource are, as their name suggest, only views . You can only manipulate the original collection. You should use an ObservableCollection if you want the changes to be automatically reflected in your UI. I would advise against using anonymous types for data binding. But if you must -

WPF CollectionViewSource Multiple Views?

南楼画角 提交于 2020-01-09 09:50:02
问题 I've written a Custom WPF Control with search extension, let's name it MyControl . The Control is a descendent of an ItemsControl class. So I feed the the data source to it like this: The control itself uses protected override void OnItemsSourceChanged(System.Collections.IEnumerable oldValue, System.Collections.IEnumerable newValue) { if (newValue != null) { ICollectionView view = CollectionViewSource.GetDefaultView(newValue); view.Filter += this.FilterPredicate; } if (oldValue != null) {

WPF CollectionViewSource Multiple Views?

拟墨画扇 提交于 2020-01-09 09:48:06
问题 I've written a Custom WPF Control with search extension, let's name it MyControl . The Control is a descendent of an ItemsControl class. So I feed the the data source to it like this: The control itself uses protected override void OnItemsSourceChanged(System.Collections.IEnumerable oldValue, System.Collections.IEnumerable newValue) { if (newValue != null) { ICollectionView view = CollectionViewSource.GetDefaultView(newValue); view.Filter += this.FilterPredicate; } if (oldValue != null) {

How do you apply multiple filter functions on one collection view source, one after another (AND relation)

断了今生、忘了曾经 提交于 2020-01-02 07:26:10
问题 I have been working with a Collection View Source object that is bound to a listview and the CVS is a view on top of Observable Collection of objects. I know how to apply a filter using the following technique: cvs.Filter += new FilterEventHandler(SomeFilterFunction); This works fine when you are only filtering in one function. The problem is when I want to filter on top of the already filtered CVS. If I have another function that filters the objects in the view based on different criteria,

Metro App CollectionViewSource ObservableCollection Filter

吃可爱长大的小学妹 提交于 2020-01-01 06:41:47
问题 It appears that filtering an ObservableCollection with CollectionViewSource is not possible in WinRT : See here! I can filter using LINQ , but how do I get the UI to update if changes that affect the filtered data are made? 回答1: I ended up writing my own class to achieve the desired effect: public class ObservableCollectionView<T> : ObservableCollection<T> { private ObservableCollection<T> _view; private Predicate<T> _filter; public ObservableCollectionView(IComparer<T> comparer) : base

DesignTime data not showing in Blend when bound against CollectionViewSource

感情迁移 提交于 2020-01-01 01:53:17
问题 I have a datatemplate for a viewmodel where an itemscontrol is bound against a CollectionViewSource (to enable sorting in xaml). <DataTemplate x:Key="equipmentDataTemplate"> <Viewbox> <Viewbox.Resources> <CollectionViewSource x:Key="viewSource" Source="{Binding Modules}"> <CollectionViewSource.SortDescriptions> <scm:SortDescription PropertyName="ID" Direction="Ascending"/> </CollectionViewSource.SortDescriptions> </CollectionViewSource> </Viewbox.Resources> <ItemsControl ItemsSource="{Binding