Тёмный

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

SingletonSean
Подписаться 22 тыс.
Просмотров 18 тыс.
50% 1

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...

Наука

Опубликовано:

 

4 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 37   
@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 20 дней назад
thanks! perfect lesson
@amryakout2957
@amryakout2957 Год назад
Great work 👏
@PythonHarry
@PythonHarry 2 месяца назад
explains a lot, thanks
@basharfocke
@basharfocke 6 месяцев назад
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.
@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 RU-vid 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?
@2005bgva
@2005bgva 2 года назад
Thanks SingletonSean for this video, could you please activate subtitles? please please.
@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.
@MohammadGolara
@MohammadGolara 3 месяца назад
How is it possible to make a new DataGrid and show how many for example Doctor is in list?
@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.
@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
@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
@_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
@mrt7948
@mrt7948 2 года назад
Can I dowoad the source code?
@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.
Далее
If You Like My Outfit Then You Are Subscribed 👀
00:12
Data Filtering in a ListView [WPF]
26:51
Просмотров 10 тыс.
The Basics of Data Binding in WPF
20:53
Просмотров 36 тыс.
Don't throw exceptions in C#. Do this instead
18:13
Просмотров 251 тыс.
Creating Reusable Controls - WPF TUTORIALS
17:10
Просмотров 29 тыс.
WPF Controls with MVVM: DataGrid
24:59
Просмотров 171 тыс.
WPF in C# with MVVM using Caliburn Micro
1:23:30
Просмотров 360 тыс.
Binding to a PasswordBox (MVVM) - EASY WPF (.NET CORE)
12:14
ПОКУПКА ТЕЛЕФОНА С АВИТО?🤭
1:00
Best mobile of all time💥🗿 [Troll Face]
0:24
Просмотров 2,3 млн