collectionviewsource

WPF: Bind/Apply Filter on Boolean Property

混江龙づ霸主 提交于 2019-12-11 12:00:01
问题 I want to apply a filter to a ListBox accordingly to the IsSelected property of a CheckBox . At the moment I have something like this. XAML <CheckBox Name="_filterCheckBox" Content="Filter list" Checked="ApplyFilterHandler"/> <ListBox ItemsSource="{Binding SomeItems}" /> CodeBehind public ObservableCollection<string> SomeItems { get; private set; } private void ApplyFilterHandler(object sender, RoutedEventArgs e) { if (_filterCheckBox.IsChecked.Value) CollectionViewSource.GetDefaultView

Filter CollectionViewSource by search string - bound to itemscontrol (WPF MVVM)

巧了我就是萌 提交于 2019-12-11 08:04:02
问题 Is there a way I can filter the CollectionViewSource to only show games in the ItemsSource which "Title" contains the "searchString"? In my PosterView I have this CVS: <CollectionViewSource x:Key="GameListCVS" Source="{Binding PosterView}" Filter="GameSearchFilter"> <CollectionViewSource.SortDescriptions> <scm:SortDescription PropertyName="Title" /> </CollectionViewSource.SortDescriptions> </CollectionViewSource> and also this ItemsControl <ItemsControl x:Name="gameListView" ItemsSource="

Any idea on how to sort a CompositeCollection?

徘徊边缘 提交于 2019-12-11 04:59:11
问题 I have a CompositeCollection that consists of ObservableCollections of two types: Companies and Contacts. Contact has a property FullName while Company has a property Name. I want to apply sorting so the collections are mixed by their types but sorted by their name, example: Itzhak Perlman John Doe Microsoft Sarah Moore StackOverflow Walter Richardson Note that I bound the ItemsControl to a CollectionViewSource that its Source is set the CompositeCollection, it's view becomes a

CollectionViewSource with Sort get sorted Items

主宰稳场 提交于 2019-12-10 17:55:50
问题 I have a datagrid which has as source CollectionViewSource with custom sorting and I need to get sorted items collection as can be seen in datagrid. I can get sorted description and sort source collection, but I need this collection many time. Is there some way how to get sorted collection which enable indexation ( item[index]) ? 回答1: The CollectionViewSource's View property returns a sorted ICollectionView. Since that is an IEnumerable, you could use Linq to create a List from it, which can

LongListSelector grouping using CollectionView in Windows Phone 7 or Windows Phone 8

∥☆過路亽.° 提交于 2019-12-10 09:22:23
问题 I am facing the same problem as listed in the below tag Is it possible to use CollectionView with LongListSelector for grouping? I use the following code to bind the LongListSelector with grouping. CollectionViewSource cv = new CollectionViewSource(); cv.Source = comments; cv.GroupDescriptions.Add(new PropertyGroupDescription("Filter")); listSelector.HideEmptyGroups = true; listSelector.ItemsSource = cv.View.Groups; But it does not display anything. Anyone can you please help me on this ? 回答1

My CollectionViewSource is not picking up changes

倖福魔咒の 提交于 2019-12-09 19:43:56
问题 I have a ListView which I'm binding to a CollectionViewSource in code behind with: collectionView = CollectionViewSource.GetDefaultView(TableView.ItemsSource); collectionView.SortDescriptions.Clear(); collectionView.SortDescriptions.Add(new SortDescription(propertyName, direction)); The TableView is the ListView, the propertyName is the name of the column I want sorted, and direction is either ascending or descending. The XAML has the following for ItemSource: ItemsSource="{Binding Rows}" The

CollectionViewSource, how to filter data?

[亡魂溺海] 提交于 2019-12-09 00:37:57
问题 I am binding a ComboBox to Entities but I want the data filtered. Up to now I have tried two ways: "simple" one: Apply the filter directly to the ObjectSet throught LINQ to Entities setting a filtering event handler as described on msdn I am satisfied by the first approach, above all because the query generated to the database contains a WHERE clause, so not all the whole data have to be retrieved from the remote db.... However, the #2 approach is by far more flexible, if at runtime i'd like

How do I sort a WPF treeview that has items bound to the properties of an Item subclass?

回眸只為那壹抹淺笑 提交于 2019-12-08 05:16:11
问题 I have two classes, public class BookItem { public string BookID { get; set; } public string ItemID { get; set; } public Item Item { get; set; } public ItemType Type { get; set; } public string ParentID { get; set; } public string BoxID { get; set; } public string StyleID { get; set; } public string NotesID { get; set; } public string Code_XAML { get; set; } public string Description_XAML { get; set; } public CompositeCollection SubItems { get; set; } } public class Item : ClaunchBaseClass {

How do I sort a WPF treeview that has items bound to the properties of an Item subclass?

不打扰是莪最后的温柔 提交于 2019-12-06 16:27:42
I have two classes, public class BookItem { public string BookID { get; set; } public string ItemID { get; set; } public Item Item { get; set; } public ItemType Type { get; set; } public string ParentID { get; set; } public string BoxID { get; set; } public string StyleID { get; set; } public string NotesID { get; set; } public string Code_XAML { get; set; } public string Description_XAML { get; set; } public CompositeCollection SubItems { get; set; } } public class Item : ClaunchBaseClass { public string ItemID { get; set; } public int Type { get; set; } public string Code { get; set; }

Windows Phone CollectionViewSort not showing anything

不羁的心 提交于 2019-12-06 13:55:20
I am trying to develop a page in a WP8 app which has a search box at the top and a list of items that match the search below, updating as the search box updates. Pretty straightforward, right? Except I can't get it to work. After perusing StackOverflow and the interwebz, the recommended solution seems to be to use CollectionViewSource . Well, I'm trying to use it and no items show up. As soon as I switch to the ObservableCollection containing my items in XAML, everything shows up fine. My data is loaded asynchronously from a DB. XAML <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" />