Тёмный

WPF Controls with MVVM: DataGrid 

IAmTimCorey
Подписаться 415 тыс.
Просмотров 171 тыс.
50% 1

If you have been following along in this WPF mini-series, this is probably the one you have been waiting for. Taking data and displaying it on a WPF form in a way that you can edit and manipulate is most easily accomplished with a DataGrid. In this video, we are going to look at how to populate a DataGrid with different types of data, including some advanced use cases.
Full courses: www.iamtimcorey.com/
Source Code: leadmagnets.app/?Resource=Dat...
Patreon: / iamtimcorey
Newsletter signup: signup.iamtimcorey.com/
0:00 - Intro
0:57 - Prerequisites
1:46 - Demo app overview
2:36 - Creating DataGrid
4:11 - Alternating row background
5:01 - Adding data
7:18 - Columns
10:56 - Dropdown in column
18:19 - Date picker
21:56 - Summary and concluding remarks
Thanks to Ralfs HBK for the chapters breakdown

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

 

2 июл 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 348   
@shawnmofid7131
@shawnmofid7131 5 лет назад
I did not think I can be so capable this fast. I realize there is a lot to learn, and appreciate so much you created this content.
@IAmTimCorey
@IAmTimCorey 5 лет назад
I'm glad you are getting up to speed so quickly.
@robertocallaghan576
@robertocallaghan576 5 лет назад
Well Done Tim, I've been a long time developer in VB and the transition to C# and WPF has been made so much easier with your tutorials, Please keep it up Thanks from down under
@IAmTimCorey
@IAmTimCorey 5 лет назад
I'm glad I could help.
@bharathyadav3614
@bharathyadav3614 5 лет назад
Hey Tim, That was quick. Thanks for obliging my request for a "DataGrid" session. Good job with the 'CellEditingTemplate'/'DatePicker', learnt something new. Looking forward to other contents on WPF... Keep up the good work. 👍
@IAmTimCorey
@IAmTimCorey 5 лет назад
Yep. It has been sitting there ready to go for a while. Glad you enjoyed it.
@RalfsBalodis
@RalfsBalodis 3 года назад
0:00 - Intro 0:57 - Prerequisites 1:46 - Demo app overview 2:36 - Creating DataGrid 4:11 - Alternating row background 5:01 - Adding data 7:18 - Columns 10:56 - Dropdown in column 18:19 - Date picker 21:56 - Summary and concluding remarks
@IAmTimCorey
@IAmTimCorey 3 года назад
Thanks again!
@d0opify
@d0opify 5 лет назад
always a blast being educated by you :)
@IAmTimCorey
@IAmTimCorey 5 лет назад
I'm glad.
@longuinni
@longuinni 5 лет назад
Really nice! Thanks for sharing all that knowledge.
@IAmTimCorey
@IAmTimCorey 5 лет назад
You are most welcome. Thanks for watching.
@hararr1980
@hararr1980 5 лет назад
Its amazing! Your examples are useful and you make that easier! Thank you ;)! The best channel with C#.
@IAmTimCorey
@IAmTimCorey 5 лет назад
I appreciate the kind words.
5 лет назад
Thank you so much Tim, this vid help me a lot! Keep on going!
@IAmTimCorey
@IAmTimCorey 5 лет назад
You are welcome.
@youtube.com-handle
@youtube.com-handle 5 лет назад
never used caliburn but you made it very easy to get used to it in two to three videos, thanks Tim
@IAmTimCorey
@IAmTimCorey 5 лет назад
Excellent!
@krishnanblr
@krishnanblr 3 года назад
clear and simple explanation. Thanks!
@IAmTimCorey
@IAmTimCorey 3 года назад
You're welcome!
@leosanni
@leosanni 3 года назад
To the point. Easy to understand.
@IAmTimCorey
@IAmTimCorey 3 года назад
Thanks!
@codewarez
@codewarez 2 года назад
this really help alot thanks
@IAmTimCorey
@IAmTimCorey 2 года назад
You are welcome.
@user-uh6qi1hr3p
@user-uh6qi1hr3p Год назад
Thanks! Very useful
@IAmTimCorey
@IAmTimCorey Год назад
You're welcome!
@accsoftware3762
@accsoftware3762 3 года назад
Thanks so much !!! It's a great tutorial, I'm speak spanish but understand all perfect!!
@IAmTimCorey
@IAmTimCorey 3 года назад
Great!
@cramtorte
@cramtorte 4 года назад
Hey Tim, REALLY terrific content!! Thank you for everything. Think you could do a more advanced video which illustrates dealing with changes in the DataGrid in MVVM? For example, only processing objects or properties which have changed. Again, thanks for all of the great tutorials and knowledge sharing!!!
@IAmTimCorey
@IAmTimCorey 4 года назад
I can add that suggestion to the list.
@user-lg2ev7lk6t
@user-lg2ev7lk6t 4 года назад
Nice, it’s useful
@IAmTimCorey
@IAmTimCorey 4 года назад
Thank you!
@andremartins4770
@andremartins4770 Год назад
Thanks so much.
@IAmTimCorey
@IAmTimCorey Год назад
You are welcome.
@heloisaduarte4745
@heloisaduarte4745 2 года назад
LMFAO... At 3:20.... LMFAO... This is the fourth or fifth video of the WPF collection that I have been watching... I can't stop laughing !!!! Your videos are awesome thank you so much!!
@IAmTimCorey
@IAmTimCorey 2 года назад
I'm glad you enjoyed it and I'm glad I could give you a good laugh.
@m1cx657
@m1cx657 4 года назад
Nice!!!!!
@IAmTimCorey
@IAmTimCorey 4 года назад
Thanks!
@KarlooAudi
@KarlooAudi 4 года назад
Thanks man.
@IAmTimCorey
@IAmTimCorey 4 года назад
You are welcome.
@zohar127
@zohar127 4 года назад
I'm gonna show this video to some of my coworkers for sure. I'm trying to convince them to move to WPF from winforms as our solution grows and grows and grows and their biggest worry is that somehow it will be be harder to work with grids. I think I'll just show them the first 5 minutes of the vid so I don't scare them off with the templating stuff :) bind to an item source. Done!
@IAmTimCorey
@IAmTimCorey 4 года назад
I am glad it can be helpful.
@_buffer
@_buffer 5 лет назад
Didnt watch it yet but the title says it's going to be good!
@IAmTimCorey
@IAmTimCorey 5 лет назад
I hope you enjoy it.
@Naeuuin
@Naeuuin Год назад
im having issues with a Ambiguity between the and the BindableCollection People
@BudiSantoso-er6cq
@BudiSantoso-er6cq 3 года назад
I'm a newbie, I'm learning DataGrid using Dapper. let me download this video. thank you Tim, God bless you ..
@IAmTimCorey
@IAmTimCorey 3 года назад
Glad it was helpful!
@zuurik666
@zuurik666 10 месяцев назад
Hey Tim! Do you have any materials on how to bind this ComboBox to List that is outside of Person model? Like if the Addresses are just a list(taken and updated from database) and you can select for every person a address from there? Makes more sense, if i have one list of address and Person model holds only the Id to that address(as its done with the WinForms combobox). I have searched a bit but haven't found as nice tutorial as you do on these topics(i even started the C# mastercourse on your website thanks to these youtube videos). Usually when the code starts to scare me, then i know that there is a simpler way to do it...
@sunayvatansever5905
@sunayvatansever5905 4 года назад
Nice
@IAmTimCorey
@IAmTimCorey 4 года назад
Thanks!
@mrspacer1
@mrspacer1 5 лет назад
thanks!
@IAmTimCorey
@IAmTimCorey 5 лет назад
You are most welcome. Thanks for watching.
@jonestako4721
@jonestako4721 5 лет назад
Thanks
@IAmTimCorey
@IAmTimCorey 5 лет назад
You are most welcome. Thanks for watching.
@solvedplus858
@solvedplus858 Год назад
hi what is the best way to array control in wpf mvvm in two dim ( in X & Y direction ) to create table of data other than datagrid
@HollandHiking
@HollandHiking 4 года назад
Hi Tim, thanks for sharing this. I use DataGrids a lot, if fact it is my major way to show tables. I use HeaderTemplates, that allow to set filters on the data, I use RowDetails, to expand a row a bit. Up till now, I did not integrate editing like you do, it's an idea to consider. At the moment I try to master DataGrids with with a variable numer of columns, which are generated dynamically. My first attempt is now working, but it only supports strings. In my second attempt I want to use objects and create a form of templating for the DataGridCells, to allow for a nicer markup. I just discovered you can freeze the first column, which is very useful. I always will use scrollbars, but this requires to fix height and width of the DataGrid. So there really is a lot you can do with this.
@IAmTimCorey
@IAmTimCorey 4 года назад
You are welcome.
@Rohan-zj8nl
@Rohan-zj8nl 3 года назад
Hi Tim, These videos are great to watch and I got to learn a lot from them. I am new to this WPF and I needed some help in grouping data in the data grid with collapsible and expandable button. This is an existing application that I am working on and it has been implemented using Caliburn Micro. So is there a simple way of doing this? Please do reply..
@hashimkz
@hashimkz 3 года назад
Hi Tim, I've been trying to bind my checkbox (inside a datagrid template column) to an event (both property setter and methods, neither worked), i tried everything i could find online for the past couple of hours but nothing seems to work. A regular checkbox works fine with the notifyOfPropertyChange, this checkbox doesn't though. I tried UpdateSourceTrigger=PropertyChanged, RelativeSource AncestorType=DataGrid, and a few other things, with different combinations (all with IsChecked, as checked would give an error), but nothing worked yet
@doluobatusin9547
@doluobatusin9547 4 года назад
Hi Tim, Thanks for the video. Please advise how to use numeric up down control to change the number of rows shown in the data grid. Thanks!
@IAmTimCorey
@IAmTimCorey 4 года назад
You would need to have the get for the list filter by the selected numeric value.
@amasoumi
@amasoumi 5 лет назад
Great Video Tim!! i was wondering if you have a video that explains all the different events on DataGrid such as BeginningEdit, PreviewLostKeyboardFocus, InitializingNewItem, CellEditEnding ... etc ?
@IAmTimCorey
@IAmTimCorey 5 лет назад
Nope, I don't. They mostly explain themselves but that might be an interesting video for the more obscure ones.
@sevabante7781
@sevabante7781 4 года назад
Hi Tim, I'm glad you're still replying to comments until this day. I do have a problem on my project. Lets say I have a datagrid with rows of numbers and I have a property to add all of those numbers. Now I want to run the addition property every time I edit a row on the UI but it doesn't. Using a button obviously works but automatically, no. I used NotifyOfPropertyChanged but it seems to not trigger it when editing on the datagrid.
@IAmTimCorey
@IAmTimCorey 4 года назад
If it runs when you click the button, run that same code where you are calling the NotifyOfPropertyChanged.
@SevAbante
@SevAbante 4 года назад
@@IAmTimCorey It doesn't trigger NotifyOfPropertyChanged which is inside the datagrid property.
@SevAbante
@SevAbante 4 года назад
@@IAmTimCorey I posted it on stackoverflow. stackoverflow.com/questions/62707786/run-a-method-after-editing-a-cell-on-a-datagrid
@stephanerichard3979
@stephanerichard3979 11 месяцев назад
I have a question. How can i make it so a column only Accepts currency values? I'm pretty sure it will be with the edit template but I'm not sure how.
@quantomic1106
@quantomic1106 4 года назад
Will there be more videos coming for this series? This has been extremely helpful. Thank you for taking the time to make them.
@IAmTimCorey
@IAmTimCorey 4 года назад
Possibly. Let me know what suggestions you have for things you would like to see.
@quantomic1106
@quantomic1106 4 года назад
@@IAmTimCorey Awesome! I'd like to see how to exactly save edits from the data grid and working with multiple views/pages. I'm still new to WPF and MVVM so excuse my ignorance.
@morphman86
@morphman86 3 года назад
Came here to see what I did wrong with adding my list of custom objects to a DataGrid source. You skipped over that part. But while writing a three-paragraph ranty text about it, checking my code and going back in your video for specifics, I figured my issue. Though you're not showing it in the video, I realized I had to both set each property I wanted to show to "public" rather than "protected" AND create the getters and setters. I had tried before by just switching them to public, but that did not work. I'm a newb when it comes to C#, so I don't yet know when it is important to specify { get; set; } yet. Most other languages I've worked with will assume these two methods on all accessible properties. Since, you know, it's rather silly to have a public property you cannot access from the outside. Anyway, great video as always, the issue was entirely on my end, and this has just been another example of how you sometimes find the answer to your problem by trying to explain it to someone else. Which I guess is why teaching others is a great way to learn yourself.
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 года назад
Thanks for sharing. I hope that will help others.
@hassanpatel3630
@hassanpatel3630 2 года назад
If I have a button with command parameter that has employee Id how do I access it in c# so I have int Id = (that command parameter employee I’d)
@VinuP2023
@VinuP2023 5 лет назад
Was waiting for it eagerly. Thanks much Just curious which is next control you are going to teach us?
@IAmTimCorey
@IAmTimCorey 5 лет назад
You will have to wait and see (although I always take suggestions).
@grampygamer8584
@grampygamer8584 5 лет назад
Works a treat. Can you pass a generic List to a BindableCollection, using a single DataGrid dependant on what DataModel is used?
@IAmTimCorey
@IAmTimCorey 5 лет назад
I'm not sure I follow your design.
@grampygamer8584
@grampygamer8584 5 лет назад
@@IAmTimCorey Basically I have a File converter for a tool I'm writing. It reads in data from a legacy system, which I convert and then upload to SQL Server tables, depending on the data model. I have a static method which I pass a file, this says Ahh! It's this Table you are dealing with (do some magic) pass back the List and my WPF DataGrid displays a sample of that converted data. So, what I did is use dynamic in the BindableCollection. Works a treat! I don't normally think of dynamics as they have a price :)
@karendoran3692
@karendoran3692 5 лет назад
Thank you for the excellent example Tim. Can you wire up for instance a click or double click event on the cell content of the datagrid and maybe have it filter the results of a particular column that you clicked in? For instance click in the Birthday column on a value with a certain year and filter the results with birthday's of that year.
@IAmTimCorey
@IAmTimCorey 5 лет назад
Yep, you can check out the event list by looking in the properties window and viewing possible events when you have selected the grid or row definition. Then you can bind it to a method in your ViewModel.
@piotrgoacki9070
@piotrgoacki9070 2 года назад
How do you normally validate the data, it seems that INotifyDataErrorInfo, which is supposedly now recommended solution by many devs doesn't gel well with DataGrid, I have also ran with issues trying to customise it
@arno94s58
@arno94s58 3 года назад
Hi, I have a question. I'm making a small Inventory system Project. I'm doing this with the MVVM framework. And in one of my views, I also using a bindableCollection to display all my customers. I also added some Delete and Edit buttons in case the user wants to delete the customer from the datagrid. I have is I would like to use some commands that are also bonded to some ICommand Classes to delete or edit some of those customers. The problem is I can't get those commands because they are not part of the bindable collection. I can only bind to the properties in my collections. What is the best way to do still use those commands? I thought of multiple item sources in order to get those commands but apparently, a Datagrid only allows one item source binding not multiple. Thanks anyway for the amazing content you give.
@jimjupiter9012
@jimjupiter9012 3 года назад
hi any help for saving a datagrid an load again with observablecollection?
@nouribenyahia8742
@nouribenyahia8742 2 года назад
Please help how to reduce the space between the lines of the Gridview . Thank you in advance, sir
@n9434178
@n9434178 5 лет назад
Great video Tim! Really usefuI. I am planning an app in which a user selects a person from the datagrid view and then opens a usercontrol to edit the person''s details in a form view. The user would then save the data (to database) and return to the datagrid. Would it be possible to show us perhaps in a future video the proper way to do that? Looking forward to see more WPF and any other topics you plan for us. Thanks.
@IAmTimCorey
@IAmTimCorey 5 лет назад
I could probably do that. For now, it should just be an event on the click event for the row where you call a method in your controller and edit that row in the new UserControl.
@markschueler5360
@markschueler5360 4 года назад
Great sets of videos I have learn a ton. I did have a question on the datagrid combox. I noticed that the down arrow is missing unless you click on the cell. Is it possible to have the arrow showing all the time? if so how?
@IAmTimCorey
@IAmTimCorey 4 года назад
That's because it isn't a combobox in view mode, it is a textblock. You can change the template to be a combobox in view mode as well, if you want.
@pierreplourde
@pierreplourde 2 года назад
Great video. One question: while I see how the edits modify the instantiated model (data in memory), how would you trigger committing the changes back to the database?
@IAmTimCorey
@IAmTimCorey 2 года назад
Put a command that observes the change and saves it to the database, or trigger a save at your convenience (maybe when they leave the form).
@jamalume
@jamalume 3 года назад
Very clearly explained, thank you. I would like user have provision to sort and filter data grid columns like Excel, It will be great if you could share a link where it has implemented or guided how it has to be done. Thank you so much.
@IAmTimCorey
@IAmTimCorey 3 года назад
I don't have an example of this. Sorry.
@philochill
@philochill 3 года назад
Hi Tim, thank you again. Your tutorials are the best! Is there an easy way to display only the persons that are alive? Even if in the Collection are people which aren’t.
@IAmTimCorey
@IAmTimCorey 3 года назад
You could query the data before loading the list so that the list is only the records you want to see.
@pukavita
@pukavita 4 года назад
This is very good! Thanks for putting effort into making this video. I’m fairly new to WPF and I’ve learnt a lot from this video. I have a question if you don’t mind... how would you do it if you’d have to highlight cells that have a certain value? Say, for example, a list of users having an “Active” column that can be “Yes”/“No” (or true/false) and you want to set the background colour to light green for all those having “Yes” in that column. Many thanks.
@IAmTimCorey
@IAmTimCorey 4 года назад
You would need to do a conditional check for each cell after each update and then update the cell's background color based upon the value.
@MegaGamers98
@MegaGamers98 5 лет назад
Thank you for the great videos. I would like to request a video on Singleton pattern. Thanks a Lot.
@IAmTimCorey
@IAmTimCorey 5 лет назад
It is on the list. Thanks for the suggestion.
@wim874
@wim874 4 года назад
These videos are very helpful, thank you. 1 small question, how can you make calculations with the rows of the datagrid so you can show them in another row? Thank you in advance
@IAmTimCorey
@IAmTimCorey 4 года назад
I don't have an example to show you of that, sorry. Typically, you would use a third-party library for this, although it can be done manually.
@VinuP2023
@VinuP2023 5 лет назад
Please make a video on Dependency property and attached property in wpf. Thank you
@IAmTimCorey
@IAmTimCorey 5 лет назад
I'll add that to the suggestion list. Thanks.
@CoderboyPB
@CoderboyPB 3 года назад
Hi Tim, if I change values, or add a new line, does that automatically change the values in the object? For example, if I have bound an Entity Framework Class to the DataGrid and I make changes in the grid, is it enough, just to call 'SaveChanges()' Method of the EF Framework?
@IAmTimCorey
@IAmTimCorey 3 года назад
Yes, changing the value changes the object.
@steliosromanopoulos4589
@steliosromanopoulos4589 5 лет назад
I saw your video "How to connect C# to SQL (the easy way) " (which is great by the way) and now this and I have a question. What can I do if I want to update the database when I write a new row into the gridview??? Basically I have a problem extracting the data from datagrid and save it as a list. Please do a video because for the last 8 hours I found nothing on RU-vid.
@IAmTimCorey
@IAmTimCorey 5 лет назад
If you do it the way I outlined in this video, you already have it outside the grid in a List. You can use that data to save it to the database.
@markfoad3809
@markfoad3809 4 года назад
Hi Tim, I can populate the WPF Datagrid - is there more information about saving the row changes back to an object model that can be saved back to SQL Database Table?
@IAmTimCorey
@IAmTimCorey 4 года назад
That isn't a UI function really. I have videos on how to save data to SQL. They are what you need to save your data back to SQL.
@sudheernani2470
@sudheernani2470 3 года назад
How can we make the DataGrid header fixed on scroll?
@siiilo
@siiilo 3 года назад
Hi! Do You have a video there you show doubleclick in datagrid and get that row in viewmodel? Im using mvvm and caliburn micro
@johanhansson2531
@johanhansson2531 3 года назад
Aaaaahh it works... it was so easy tbh :) Love it!
@v3dmodels593
@v3dmodels593 5 лет назад
Hi Tim, how would I get all the displayed data out of that datagrid and into a sql server table? Coming from winforms I cannot use row.Cells[0] anymore
@IAmTimCorey
@IAmTimCorey 5 лет назад
The ViewModel has the list of your data. That is the data you use to save to the database. You don't need to query the UI to get the data back.
@alphabetta7837
@alphabetta7837 Год назад
Nice video what is left here to add some demo for changing column order (DisplayIndex)
@IAmTimCorey
@IAmTimCorey Год назад
Thanks!
@lordamateur
@lordamateur 4 года назад
Hi, Thanks for the videos but I think the wpf series is highly missing a tutorial for events (or event aggregation) on caliburn micro. Can you please make a tutorial on that?
@IAmTimCorey
@IAmTimCorey 4 года назад
You can see events and event aggregation in the TimCo Retail Manager series, where we have an API middle layer and a WPF front-end. Specifically, when the user logs in, it fires an event that opens up a new form.
@majordan9747
@majordan9747 4 года назад
You are big help. Own you beer.
@IAmTimCorey
@IAmTimCorey 4 года назад
I'm glad I've been helpful.
@epichalo3
@epichalo3 5 лет назад
Hey Tim, you got some awesome and informative videos! I have a quick question, how would you set a button that would delete a row that the user selected from the DataGrid? I'm trying to figure out how to retrieve the data in that selected row to be used to pass a query to my SQLite database. For example, following your video, I would click on a "Full Name" row and click a delete button that would retrieve all the data of that person (Birthday, address, etc..). From there, the rest of the code would use that data to fill in a delete query to a SQLite database. Any advice would be appreciated!
@IAmTimCorey
@IAmTimCorey 5 лет назад
I think you need to set up a model for selected row and then just remove that row when the button is pressed.
@shawnmofid7131
@shawnmofid7131 5 лет назад
Tim does not x:Name define the name of the UI control? So if we use the same name for a property and a UI component, CM renders it? ( I hope I used the right technical words ) And if the UI control like TextBlock does not have x:Name option, we use Binding right?
@IAmTimCorey
@IAmTimCorey 5 лет назад
Yes, CM looks at the name and binds it to the matching property (if it exists). We can also use the binding if we need to (usually special cases).
@duncancarr7822
@duncancarr7822 4 года назад
Hi. A year late, but I've spent the last couple of days with just this problem - a combo box with binding (the default one doesn't appear to do anything due to the information it is "fed" from the partent datagrid from my understanding. Maybe I am talking rubbish. But this did work for me ...
@IAmTimCorey
@IAmTimCorey 4 года назад
I'm glad you got it to work.
@VinuP2023
@VinuP2023 5 лет назад
Hi Tim, I was playing around with Datagrid in this demo. One feature that came to my mind was how to implement Find and replace functionality as we see in Microsoft Excel. This was a practice and to do problem solving. I bind datagrid item source to a datatable in my viewmodel. To implement Find and replace functionality, i found one approach but couldn't achieve it. It is like this: I compare a textbox value entered by user with one datatable column's value, and change those value with a new textbox value(say RepalcetextBox), but after I bound data to datagrid, I couldn't compare data column value with textbox value as now I have to deal with DataGrid data and not DataTable values. Can you please tell me if my approach is correct or where I'm going wrong. Do you see think of any other approach I can achieve?
@IAmTimCorey
@IAmTimCorey 5 лет назад
I would work directly with the models, not with the UI elements. So when you do a Find and Replace, don't search the DataGrid, search the List that supports the DataGrid. Then replace in them.
@jrichardw
@jrichardw 4 года назад
Hey Tim...using caliburn micro (or anything else) is there a way to get the datagrid to refresh without code-behind? I have a form that creates the new item and a button in the datagrid that deletes it; but it's not refreshing. My Datagrid is is named the same thing as my bindablecollection.
@IAmTimCorey
@IAmTimCorey 4 года назад
You should be updating the grid by adding to the ViewModel, not by manipulating the grid directly.
@jrichardw
@jrichardw 4 года назад
@@IAmTimCorey Not sure I follow just yet. So I have a ViewModel (SettingsViewModel) that loads up a Model called LinkPatterns. this is getting data the same your your example does: DataAccess class that loads data into the LinkPattern model from the app.config file. I'm calling DataAccess from the SettingsViewModel contructor so it loads at startup. Datagrid is populated just fine there. Based on your response, I think the problem is when I add a new link pattern, I'm adding by a method that writes xml to the app.config file directly. Soooo, basically nothing is going to automatically load this datagrid with the new entry until my VM opens again. I'm not very advanced, but I think I can find my way around adding my new pattern to the collection, but won't collection have all of my previous records there? If so, I don't know how to only write the new one.
@anaraliyev214
@anaraliyev214 3 года назад
Hi Tim, I appreciate your input in making concept of learning C# easier, since I've watched lots' of video tutorials you've posted there. They are mostly very clear and intuitive to get close with the idea. But I have one very big notice regarding MVVM-concept and it's regarding the Caliburn Micro: I would like to implement MVVM without Caliburn micro. Is there any plans to make some observable video with datagrids and comboxes (for example) on this topic. Thank you in advance.
@IAmTimCorey
@IAmTimCorey 3 года назад
Hint: When you go to my channel page (ru-vid.com/show-UC-ptWR16ITQyYOglXyQmpzw), use the SECOND search option which is under the Subscribe/Unsubscribe button to search my channel. If you look for 'MVVM', for example, you would find these items to address your needs - ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-zvyQNuuTqks.html (Datagrid) and ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-nKJ_XDoAdtY.html (Combobox)
@anaraliyev214
@anaraliyev214 3 года назад
@@IAmTimCorey thank you for the reply, I'll try it out. And once again thank you for the great input.
@santanukumarprusty6592
@santanukumarprusty6592 3 года назад
Can we show only month and year in date picker . Is there any string format for that ?? Bdw great informative video . Thanks 🙂
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 года назад
Thanks for watching and posting a question.
@rajashekharh756
@rajashekharh756 4 года назад
Hi Tim, I have data grid on the page....and I have enabled Canfilter property so when I mooise curser over grid column head I can see a tiny text box to filer the perticular column values...so here we ge on my question... When I click on the text box n type any character the data grid will get filtered ..but the text in the textbox which in next to grid header will remains untill unless we manually clear it....so here I want to clear that text when we click on cancel button(it's one of the button on my screen)...can you please help me on this ... Thanks
@IAmTimCorey
@IAmTimCorey 4 года назад
The textbox is bound to a property so when you hit the cancel button, clear out the property value and it will clear out the textbox.
@Milan-rc8qg
@Milan-rc8qg 4 года назад
Hi Tim, Thanks for the amazing Tutorial. I am currently building a Datagrid and it has a column that is supposed to provide a drop down with a editable textbox in case if the desried value is not in the drop down. my datagrid is bound to a datatable. It takes in the value i enter correctly, but while displaying it splits the value into single characters and displays them as sepearet items. Would be glad to hear from you.
@IAmTimCorey
@IAmTimCorey 4 года назад
It looks like you are binding the ComboBox ItemSource to a single item. You need to bind it to a list of items (the items in the dropdown).
@solvedplus858
@solvedplus858 4 года назад
You are awesome many thanks for the magnificent tutorial but what is the BindableCollection is?? and how to bind data in excel to datagrid (number of columns & names are not know)? thanks again
@solvedplus858
@solvedplus858 4 года назад
i mean in your example you have property for each column but when getting data from excel, i don't know how many columns and don't its type either
@IAmTimCorey
@IAmTimCorey 4 года назад
You would need to figure that out at some point. When you get data from Excel, you would need to put it into columns and rows. To use it effectively in C#, you would then need to assign that data to a strongly-typed object that has defined properties. Otherwise you can't do easy binding like this. You will need to do a more manual binding process.
@solvedplus858
@solvedplus858 4 года назад
@@IAmTimCorey first, many thanks for your fast replay i do put the excel data in datatable, i hope this not breaking the MVVM pattern but i can't have full control on it,i miss the properties to bind it as i wish also, i found it too hard to create checkbox column and bind it to row selection , so i can only processing the selected data i hope you can make more videos on this complicated control i'm in this for more than three weeks, but progress is too slow thanks
@kostickar777
@kostickar777 4 года назад
Hello Tim, very quick question. What is the difference between Binding ="{Binding FullName}" and Binding="{Binding Path=FullName}" the reason why I am asking this, is because looking back at the other tutorials you used mostly the version without path and because both seem to work.
@IAmTimCorey
@IAmTimCorey 4 года назад
Path is typically implied.
@systematicloop3215
@systematicloop3215 5 лет назад
What would you recommend as a replacement for the Windows Forms PropertyGrid? I find it strange how there does not seem to be one in WPF when Microsoft very clearly has one built for their own use in several of their applications that utilise WPF, or so it would seem.
@IAmTimCorey
@IAmTimCorey 5 лет назад
Off the top of my head, I can't think of one but I can look into it.
@andywalter7426
@andywalter7426 4 года назад
I have one question about data grids or other controls. If a person wanted to have several buttons and when you click on the button, then it runs a command on the view model, how can that be done with caliburn micro? I've done it before with old fashioned Command. However, I would prefer to be able to invoke a method without the commands. What I would want is when they click on an item, that becomes the parameter that gets sent to the method and even having the Can so if the validation fails, then the button would be disabled.
@IAmTimCorey
@IAmTimCorey 4 года назад
You can do that. The button can actually be in the model that you have a list of. You could also have the button send the row information on click I believe. Sorry, I don't think I have an example right at hand to show you.
@joellustigman
@joellustigman 4 года назад
Hi first thank you for all your hard work :-). I am working on a datagrid where the data source is a request to a api how would I go about fetching more data from the api when the user scrolls to the bottom of the datagrid or a few rows before so by the time the user gets to the bottom new data has already been appended?
@IAmTimCorey
@IAmTimCorey 4 года назад
You would just need to call the API like normal but pass in your offset (which page of data you want).
@gabrieltoh2169
@gabrieltoh2169 3 года назад
Great explanation, Is it possible to make a video on how to set DataGridTemplateColumn visibility via Binding using mvvm?
@IAmTimCorey
@IAmTimCorey 3 года назад
I will add it to the list. Thanks for the suggestion.
@gabrieltoh2169
@gabrieltoh2169 3 года назад
@@IAmTimCorey maybe u can teach me?
@BartEndhoven
@BartEndhoven 3 года назад
Thanks Tim, Great videos! Im am looking for changing the background color of a specific cell, Every cell contains a object Bag. This Bag has a TrialId. I want to give every cell with TrialId "1" the same background color. the same for every trial. So that i have a nice overview of all the cells with the attached trial. Do you know if i can do this in a datagrid, or maybe you have a different solution. Thanks for helping!
@IAmTimCorey
@IAmTimCorey 3 года назад
I don't have sample code for that, sorry.
@ziyadhazim2417
@ziyadhazim2417 5 лет назад
Your lessons are wonderful ... Thank you too much Sir. My question … are you think to do lectures in analyzing “Big data” using Excel, depending on “data mining Excel AddIns tools”, and also by using the some intelligence techniques like “Genetic Algorithm Excel AddIns tools” thank you too much and I wish you always success
@IAmTimCorey
@IAmTimCorey 5 лет назад
I'll be doing some things with Excel (exporting to and importing from Excel in C#) but I doubt I'll get into Big Data or data mining. That is kind of outside the scope of this channel.
@ziyadhazim2417
@ziyadhazim2417 5 лет назад
Thank too much Dear Doctor I hope that this will be within your interests in the future at least to deal with the data mining tool (AddINS) and how to add it to excel and deal with it and is it free and possible to be added at any time ...
@tessvandiepenbos
@tessvandiepenbos 4 года назад
Hello Tim, Do you have any tips on how to use a listbox in MVVM?
@IAmTimCorey
@IAmTimCorey 4 года назад
It is very similar to a combo box. I have a video on the combo box so you should be able to do everything in that video but with a listbox.
@wagnereliasdeandrade
@wagnereliasdeandrade 3 года назад
How can I pass a list of objects to rowdetail?
@rmysterios
@rmysterios 4 года назад
Hi. Great tutorials. I am relatively new to WPF and was wondering if you could help me with something. I have a similar DataGrid with a Boolean value like isAlive. I get the data for the DataGrid from a SQL Server Database table using Dapper and Stored Procedures. It shows the data fine. But say I wanted to change the Boolean value in the DataGrid from false to true and vice versa, and wanted to reflect the change in the database (maybe using a stored procedure with an update statement?). Is there an easy way to do this? I am also using Caliburn Micro btw.
@IAmTimCorey
@IAmTimCorey 4 года назад
Yep, you could capture the click event on a button in the grid row that toggled the status. In that same event, you could trigger an update stored procedure and you would be all set.
@josephniccoli617
@josephniccoli617 5 лет назад
is there a video before this one? i have to create a table and fill it with data from tsql and this is what im looking for
@IAmTimCorey
@IAmTimCorey 5 лет назад
I show you how to create tables and populate them in the TimCo Retail Manager series. I also have a course titled "SQL Developer from Start to Finish" that would be really helpful.
@pricesmith5558
@pricesmith5558 4 года назад
Dumb question... where/what are the videos leading up to this? Building the VM and the M etc etc.. Definitely going to dive into that!
@IAmTimCorey
@IAmTimCorey 4 года назад
Not a dumb question. Here's the WPF playlist: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-gSfMNjWNoX0.html
@spazieren99
@spazieren99 2 года назад
Hello Tim, thanks a lot for this valuable content. I have one question: When do you use just {Binding FullName] and when {Binding Path=FullName} ?
@pexoto5093
@pexoto5093 Год назад
as far as i know, both mean the same thing, except that one is more verbose
@ChantingInTheDark
@ChantingInTheDark Год назад
@@pexoto5093 - Correct
@hiromijorge400
@hiromijorge400 3 года назад
Hi Tim, from this video we can see that the data is static and if you don't mind I want to know what if we want dynamic data in the datagrid I mean the user can input like microsoft excel so we don't need to initialize the data first. thank you and god bless you
@IAmTimCorey
@IAmTimCorey 3 года назад
You can't really make a grid like Excel. You need to know what to do with the data once it is input.
@MrBigboyTX
@MrBigboyTX 5 лет назад
Hi Tim - Your videos have been so much help! I am able to use DataGrid with Caliburn Micro as you have described. What I am really struggling with is how to get the column index for a selected cell. I have tried every combination that I can think of for SelectedUnit = Cell with SelectedCells, SelectionChanged, SelectedCellsChanged, etc. and I have had no success linking my view and my viewmodel at the cell level. Any advice would be greatly appreciated. Thanks!
@IAmTimCorey
@IAmTimCorey 5 лет назад
I believe the solution isn't to try to get the selected row by index but rather through the binding. Bind an object to SelectedItem and you should be set.
@MrBigboyTX
@MrBigboyTX 5 лет назад
@@IAmTimCorey Thanks Tim. I was able to bind a ViewModel property to CurrentCell and get the column index from the associated DataGridCellInfo. When Caliburn uses Name to bind a BindableCollection to a DataGrid, is it possible to assign property values to the DataGrid object programatically from within the ViewModel? I have tried but don't know how to access the DataGrid object from within the VM (I can only access the Collection). Thanks again for everything!
@henrivandamme570
@henrivandamme570 5 лет назад
@@IAmTimCorey I tried doing that but the binding doesn't seem to work. Why could that be? I can only presume no item is selected when I push the corresponding button (although the line with the button is colored dark blue so should be selected...)?? Binding using SelectedItem with ItemsControl does work out well so it's not that I cannot work with the "SelectedItem" property and bind it to an Object.
@hamzaelmakhtari
@hamzaelmakhtari 4 года назад
Hey Tim I just want to add data (your api exercise data ) and populate in in the DataGrid. Before it was easy cause u could create the columns and select a datasource. I have no idea how to insert simple data in this datagrid... You start off with a complex data source
@IAmTimCorey
@IAmTimCorey 4 года назад
The data source isn't really important. You can just cut that part out and put in sample code or call an API. Up to you. You just need a List with your data but where it comes from doesn't really matter.
@shawnmofid7131
@shawnmofid7131 5 лет назад
When do we use binding alone, and when do we use a path please? Also do we have to use propfull or other types work with CM and XAML rendering?
@IAmTimCorey
@IAmTimCorey 5 лет назад
Path is being explicit. Sometimes you need to be explicit when other parameters are involved or you have other properties coming in. In general, you don't need it but if you have a problem, adding it can't hurt and can sometimes be the solution.
@shawnmofid7131
@shawnmofid7131 5 лет назад
@@IAmTimCorey Thanks.
@Carlozei1337
@Carlozei1337 5 лет назад
I like to get at least a bit of auto-completion and also prevent typos especially in my xaml so I use to set up a bit of help. xmlns:d="schemas.microsoft.com/expression/blend/2008" xmlns:vm="clr-namespace:ProjectXYZ.UI.WPF.ViewModel" d:DataContext="{d:DesignInstance vm:ContainerDetailViewModel}" ... Would you recommend doing this or are there some critical deficits to this?
@IAmTimCorey
@IAmTimCorey 5 лет назад
That works and there isn't a problem with it.
@ahmadkelany
@ahmadkelany 5 лет назад
Hello, Sorting on column-header click for the data template column doesn't work directly in this example, we need to set the SortMemberPath attribute to enable sorting. Just for other beginners like me who face the same issue.
@IAmTimCorey
@IAmTimCorey 5 лет назад
Thanks for sharing.
@yazan.kioumgi
@yazan.kioumgi 5 лет назад
Why are you using "." and not "_" when binding to a property of a property of the view model? Which one is the right one? Are they interchangeable?
@IAmTimCorey
@IAmTimCorey 5 лет назад
I use a dot whenever I can but if there is a situation where the binding won't work with a dot (where it conflicts) then I use the underscore.
@shuttereff3ct593
@shuttereff3ct593 4 года назад
How would I save the BindableCollection to EF Core ? .AddRange() is not working for some reason .. Thank you ..
@IAmTimCorey
@IAmTimCorey 4 года назад
Sorry, that isn't something I can really answer for you.
@metekaba6532
@metekaba6532 4 года назад
Hi Tim Corey. thanks for this freat tutorial :) It really helped me to learn datagrids in c# but I have a question. I am developing a point of sale program which has a datagrid for the products. If the person enters the same product so just the quantity cell will be increased. So my question is how to get a specific column of a row in datagrid(not selected row!). I do not know why I got stuck about this info and I really researched over the internet detailed but still I could not find any solution. Could you please help me? I tried the following code: int colNo=1; int amount=0; for (int rowNo = 0; rowNo < dgProducts.Items.Count; rowNo++) { DataRowView rowView = (dgProducts.Items[rowNo] as DataRowView); //Get RowView if (rowView[colNo].ToString() == txtProductBarcode.Text)//If there is already the same item on the list, then confirm to add them together or not. { if (MessageBox.Show("There is already the same item in the list. Would you like to sum them?", "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { amount += Convert.ToInt32(rowView[colNo]); rowView.BeginEdit(); rowView[colNo] = amount; rowView.EndEdit(); dgProducts.Items.Refresh(); // Refresh table addNewProductLine = false; break; } But it does not work :/ I could also send you the program's pictures if you have any e mail. Thanks in advance and thanks for this tutorial :)
@loreandevries4625
@loreandevries4625 4 года назад
Could you maybe do a video explaining the Dispatcher in WPF ?
@IAmTimCorey
@IAmTimCorey 4 года назад
I will add it to the list. Thanks for the suggestion.
@mohammadsorour1
@mohammadsorour1 2 года назад
I was searching for this for a decade. thank you sir. I have a question, how can I align the Column header to the right and also the text that will be inserted under the column to bel aligned to right?
@mohammadsorour1
@mohammadsorour1 2 года назад
If their is a way to make a custom style to use it every time I want to implement the right alignment.
@yourdailydoseofcode
@yourdailydoseofcode 3 года назад
What should I do if I want to display dynamic data? For example I don't know if I have 15 Colums or 120, it depends on the content in the database
@IAmTimCorey
@IAmTimCorey 3 года назад
That's when you use the auto for the column display. It will handle setting up all of the columns.
@efsanetespit7020
@efsanetespit7020 5 лет назад
How can I achieve to center WPF DataGridColumnHeader and ColumnCells; I want to set all cells and column headers as horizontal center?
@IAmTimCorey
@IAmTimCorey 5 лет назад
This should help: stackoverflow.com/questions/19131091/align-datagrid-column-header-to-center
Далее
Intro to UWP (Universal Windows Platform) Apps in C#
1:03:45
WPF Controls with MVVM: ItemsControl
33:34
Просмотров 82 тыс.
치토스로 체감되는 요즘 물가
00:16
Просмотров 4,2 млн
Фэйворит жвачка А? (2024)
01:00
Просмотров 358 тыс.
WPF Controls with MVVM: ComboBox
37:04
Просмотров 105 тыс.
Is LEARNING WPF still WORTH it in 2023?
10:59
Просмотров 40 тыс.
WPF Controls: Learn basic WPF controls in C#
29:48
Просмотров 177 тыс.
WPF in C# with MVVM using Caliburn Micro
1:23:30
Просмотров 360 тыс.
WPF UI/ Design a Modern Login Form/ Introducing to WPF
25:00
치토스로 체감되는 요즘 물가
00:16
Просмотров 4,2 млн