No video

Filtering, Sorting, and Grouping w/ Collection Views - EASY WPF (.NET CORE)

  Рет қаралды 18,207

SingletonSean

SingletonSean

Күн бұрын

Learn how to use collection views in WPF to quickly implement filtering, sorting, and grouping on a collection of items bound to the view. I also point out some interesting behavior regarding WPF default collection views.
TIMESTAMPS:
0:00 - Introduction
0:12 - Demo Introduction
0:49 - CollectionView Setup
2:05 - Filtering
4:39 - Grouping
5:48 - Sorting
6:58 - Using w/ Lists
7:30 - Other GetDefaultView Behavior
8:44 - Multiple ListView Behavior
MICROSOFT COLLECTION VIEW DOCS: docs.microsoft.com/en-us/dotn...
SOURCE CODE: github.com/SingletonSean/wpf-...
OTHER LINKS:
Donations: www.paypal.com/biz/fund?id=UB...

Пікірлер: 38
@omostan
@omostan 4 күн бұрын
As always, this is another awesome tutorial. Thank you very much for the great explanation 👍
@riyadamrani
@riyadamrani 3 жыл бұрын
Much needed tutorial thank you !
@VinuP2023
@VinuP2023 3 жыл бұрын
Thank you so much for making this video. :)
@kritikyorumer
@kritikyorumer 2 жыл бұрын
Thanks Sean!
@nikolaidavydov7523
@nikolaidavydov7523 Ай бұрын
thanks! perfect lesson
@amryakout2957
@amryakout2957 Жыл бұрын
Great work 👏
@PythonHarry
@PythonHarry 3 ай бұрын
explains a lot, thanks
@basharfocke
@basharfocke 7 ай бұрын
another perfect lesson.
@ohnomyhandleistaken
@ohnomyhandleistaken 3 жыл бұрын
Sean, your videos are always extremely helpful and I've learned a lot from them. I have one question: What happens if the ObservableCollection is loaded async into an async ViewModel, like in your MVVM full stack episode #4 ? Having tried this, the ObservableCollection gets hydrated after the view model is returned, so placing the CollectionViewSource initialization in the ViewModel constructor or the static "factory" method you create in that episode results in the CollectionView never getting populated. What would be an elegant solution for this ?
@longuinni
@longuinni 3 жыл бұрын
Really nice!! I did something very similar in my application. But how to highlight the search text? Maybe a style inside the xaml listview?
@SingletonSean
@SingletonSean 3 жыл бұрын
Hmm I could see how that would be helpful. I'm interested in how something like that would be implemented. Good questions Fernando, I'll have this in the back of my mind.
@longuinni
@longuinni 3 жыл бұрын
@@SingletonSean Yes, because if you have a large data table with long phrases it's hard to see why that result was filtered.
@ShinyBorel
@ShinyBorel 3 жыл бұрын
Very nice video, have you found a good solution for sorting groups? The best way I've got is making sure to populate the collection in the right order. But that's not dynamic or often even possible.
@SingletonSean
@SingletonSean 3 жыл бұрын
Hey ShineyBorel, I've actually never run into this kind of requirement in an application, but I am interested in messing around with this and seeing if there's a way to sort groups.
@MohammadGolara
@MohammadGolara 4 ай бұрын
How is it possible to make a new DataGrid and show how many for example Doctor is in list?
@iftaker1
@iftaker1 3 жыл бұрын
I was wondering if you can apply the same concept on Treeview?
@SingletonSean
@SingletonSean 3 жыл бұрын
Yep, I've used this before on a TreeView ItemsSource.
@2005bgva
@2005bgva 2 жыл бұрын
Thanks SingletonSean for this video, could you please activate subtitles? please please.
@amryakout2957
@amryakout2957 Жыл бұрын
I want to make filtering to datagrid with datatable or dataview not observable collection.i try it but the datagrid didn't updated anywhere
@amryakout2957
@amryakout2957 Жыл бұрын
I am working on mvvm with sql database and want to make text box filer for the data grid . I benefited alot from your channel
@apeshape01
@apeshape01 2 жыл бұрын
Hi Sean - thanks once again for your great video. I’ve followed your 4 hour video on creating a .net 5 MVVM WPF app, applying the principles to my use case. I now need to filter the list view via a text box and was going to use your video but it seems ICollectionView isn’t available in .net 5 or 6. Are you aware of what alternatives are available? I’ll continue searching but perhaps a side tutorial extending the KZbin viewers app with this capability would be brilliant. I completely understand if you’re busy on other projects though. Thanks for your time. Roy
@SingletonSean
@SingletonSean 2 жыл бұрын
Hello Roy! I am on .NET 6 and am able to use ICollectionView. Are you able to import System.ComponentModel?
@apeshape01
@apeshape01 2 жыл бұрын
Hi @@SingletonSean - that is strange. Yes I can import System.Component model namespace into my view model class but ICollectionView doesn’t come up. I’m using .Net 6 too. The Microsoft api doc doesn’t list any core or .net versions in the Applies to section. I wonder how you’ve been able to get it to work
@TheInevitable360
@TheInevitable360 Жыл бұрын
Same issue here. have you found any solution to this issue?
@kentswan3230
@kentswan3230 3 жыл бұрын
My application views are eventually bound to a database search query collection which is a subset of the entire db as filtered by the query. This can still be a lot of data. The resulting query has many more useful column elements than I want to display at first. What I actually would actually like to be able to do is selectively enable a subset of those data columns making them visible then have a user control which can dynamically enable/disable the visibility of other columns having useful data by using some sort of column enable/disable visibility selector mechanism.
@SingletonSean
@SingletonSean 3 жыл бұрын
Hey Kent, I've seen this use case implemented before. As you've probably already discovered, there is no Visibility property on GridViewColumns. The best alternative to hide a GridViewColumn is to set the Width to 0 and set the GridViewColumnHeader's IsEnabled to false to prevent resizing. That said, you could bind these 2 properties to a checkbox with converters. Hope that helps spark some ideas, Kent!
@kentswan3230
@kentswan3230 3 жыл бұрын
@@SingletonSean Thanks. That is an approach that I will try to see how well it might work.
@mrt7948
@mrt7948 2 жыл бұрын
Can I dowoad the source code?
@_SkyDancer
@_SkyDancer 2 жыл бұрын
How to use this CollectionView if I bind to the Model in the code-behind like this: var newBinding = new Binding(string.Format("[{0}]", i)); var currentColumn = new DataGridTextColumn { Binding = newBinding, Header = header }; MyDataGrid.Columns.Add(currentColumn);
@_SkyDancer
@_SkyDancer 2 жыл бұрын
The solution is - it works the same way just need to re-create and refresh collectionView after each Serialization
@user-xg7hi5mh3g
@user-xg7hi5mh3g Жыл бұрын
Hi thank u so much for your time&efforts here but I have a qst : List and every single Room have some Desktop so my List is a list of a list of Desktop how i could visualize all of this in a listBox with the template of subItem that mean that i see something like this: Room a Desktop 101 Desktop 104 Room b Desktop 234 Desktop 123 Desktop 453 Desktop 498 Room c Desktop 365 Desktop 908 Desktop 187 Room d Desktop 007 Room n Desktop 980 Desktop 1001 As we know in the list they re already grouped by a room ;) I am using json for import the list In a Wpf desktop app Thank u in advice
@laljigoti3711
@laljigoti3711 3 жыл бұрын
love your contribute and learnt a lot...first time I have spended thru paypal @lalji Goti ....Thanks
@SingletonSean
@SingletonSean 3 жыл бұрын
Thanks so much Lalji, the contributions are greatly appreciated! I'm glad my content is helping you as well.
@aminejadid2702
@aminejadid2702 3 жыл бұрын
Maybe you should use Rx.Net
@SingletonSean
@SingletonSean 3 жыл бұрын
Started getting into Rx a lot more recently, I love it! I agree, filtering is a pretty good use case for Rx.
Brutally honest advice for new .NET Web Developers
7:19
Ed Andersen
Рет қаралды 118 М.
路飞太过分了,自己游泳。#海贼王#路飞
00:28
路飞与唐舞桐
Рет қаралды 38 МЛН
Playing hide and seek with my dog 🐶
00:25
Zach King
Рет қаралды 36 МЛН
Data Filtering in a ListView [WPF]
26:51
Tactic Devs
Рет қаралды 10 М.
Async Commands (and Async Relay Command) - EASY WPF (.NET CORE)
14:14
Binding to a PasswordBox (MVVM) - EASY WPF (.NET CORE)
12:14
SingletonSean
Рет қаралды 21 М.
What is the MVVM pattern, What benefits does MVVM have?
22:38
James Montemagno
Рет қаралды 95 М.
C#/WPF - Learning the DataGrid
1:42:38
Kevin Bost
Рет қаралды 10 М.
WPF Controls with MVVM: ComboBox
37:04
IAmTimCorey
Рет қаралды 106 М.
Creating Reusable Controls - WPF TUTORIALS
17:10
SingletonSean
Рет қаралды 30 М.
A Complete .NET Developer's Guide to Span with Stephen Toub
1:02:48