collectionviewsource

Metro App CollectionViewSource ObservableCollection Filter

谁说胖子不能爱 提交于 2019-12-03 20:43:39
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? 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(comparer) { } public ObservableCollectionView(IComparer<T> comparer, IEnumerable<T> collection) : base(comparer,

WPF DataGrid Filtering - Refreshing CollectionViewSource Refreshing

扶醉桌前 提交于 2019-12-03 15:01:26
I want to know how I can refresh a CollectionViewSource when a button is clicked? So far I have <Window.Resources> <CollectionViewSource x:Key="cvsCustomers" Source="{Binding CustomerCollection}" Filter="CollectionViewSource_Filter" > </CollectionViewSource> </Window.Resources> Which creates the CollectionViewSource... <DataGrid HorizontalAlignment="Left" Height="210" Margin="47,153,0,0" VerticalAlignment="Top" Width="410" ItemsSource="{Binding Source={StaticResource cvsCustomers}}" CanUserAddRows="False" Which binds the source to my Datagrid private void CollectionViewSource_Filter(object

How to automatically update filter and/or sort order on CollectionViewSource, when an individual item's property changes?

你说的曾经没有我的故事 提交于 2019-12-03 12:30:11
Ok, so this question is related to Windows Phone 7/Silverlight (updated WP7 Tools, Sept 2010), specifically filtering an underlying ObservableCollection<T> . In mucking about with the WP7 template Pivot control application, I've run into an issue whereby changing an underlying item in an ObservableCollection<T> , does not result in the on-screen ListBox being updated. Basically, the sample app has two pivots, the first directly bound to the underlying ObservableCollection<T> , and the second bound to a CollectionViewSource (i.e., representing a filtered view on the underlying

DesignTime data not showing in Blend when bound against CollectionViewSource

北战南征 提交于 2019-12-03 06:08:25
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 Source={StaticResource viewSource}}" Height="{DynamicResource equipmentHeight}" ItemTemplate="

CollectionViewSource sorting only the first time it is bound to a source

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 01:37:27
I'm using a DataGrid bound to a CollectionViewSource ( players ), itself bound to the currently selected item of a ListBox ( levels ), each item containing a collection to be sorted/displayed in the DataGrid: <ListBox Name="lstLevel" DisplayMemberPath="Name" IsSynchronizedWithCurrentItem="True" /> ... <!-- DataGrid source, as a CollectionViewSource to allow for sorting and/or filtering --> <CollectionViewSource x:Key="Players" Source="{Binding ElementName=lstLevel, Path=SelectedItem.Players}"> <CollectionViewSource.SortDescriptions> <scm:SortDescription PropertyName="Name" /> <

Numerical string sorting in a listbox

谁说我不能喝 提交于 2019-12-02 14:59:50
问题 I have a ListBox which ItemSource is bound to a CollectionViewSource . The CVS Source is an XmlDataProvider . So the ListBox lists all nodes (name attribute) i specified. Now those nodes have attributes, and i want the ListBox to be sorted by them. The problem is, since the underlying data is xml, every value(attributes of the node) is a string, but some of the values represent numerical values. Since sorting with CollectionViewSource.SortDescriptions.add (...) will sort those (string)values

Mock data not showing when bound to ICollectionView

我的梦境 提交于 2019-12-02 09:36:09
问题 If I bound my ListBox to ViewModels ObservableCollection or XAML resourced CollectionViewSource , the mock data shows while in design. Sometimes CollectionViewSource stops showing this data because of some XAML changes, but after rebuilding the code it fills controls back with fake data again. Grouping, sorting and filtering in my case are controlled in ViewModel (and retried from database) so I decided to move over to ICollectionView property based in ViewModel. Unfortunately Views are no

Confused about CollectionViewSource (SelectedItem not working in combos)

空扰寡人 提交于 2019-12-02 00:18:15
问题 I have a bunch of combos that all share the same available choices. These choices are provided in a collection exposed from my ViewModel. All fine and dandy. I now want these choices sorted, so I decided to expose an ICollectionView from my ViewModel instead of my usual ReadonlyObservableCollection<T> , and sort the collection view in my ViewModel. class EditStuffViewModel : ViewModelBase { public EditStuffViewModel (ObservableCollection<Choice> choices) { Choices = new CollectionViewSource()

Confused about CollectionViewSource (SelectedItem not working in combos)

落花浮王杯 提交于 2019-12-01 20:27:20
I have a bunch of combos that all share the same available choices. These choices are provided in a collection exposed from my ViewModel. All fine and dandy. I now want these choices sorted, so I decided to expose an ICollectionView from my ViewModel instead of my usual ReadonlyObservableCollection<T> , and sort the collection view in my ViewModel. class EditStuffViewModel : ViewModelBase { public EditStuffViewModel (ObservableCollection<Choice> choices) { Choices = new CollectionViewSource() { Source = choices }.View; Choices.SortDescriptions.Add(new SortDescription("Name", ListSortDirection

How to get Items count from CollectionViewSource?

北战南征 提交于 2019-12-01 14:50:35
问题 I am using CollectionViewSource to filter the records displayed in a ListBox. The xaml follows. <Window x:Class="WPFStarter.ListBoxItemsFilter.ListBoxFilterUsingCollectionViewSource" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="userControl" Title="ListBoxFilterUsingCollectionViewSource" Height="300" Width="300"> <Window.Resources> <CollectionViewSource Source="{Binding ElementName=userControl, Path=DataContext