WPF Controls with MVVM: ComboBox

  Рет қаралды 106,477

IAmTimCorey

IAmTimCorey

Күн бұрын

Designing WPF controls, especially with MVVM, can be tricky so I decided to create a mini-series on the various controls we have access to in WPF and how you can wire them up properly. Even if a video covers a control you are familiar with, you will probably see an advanced use case or two that will be of benefit. In this first video, we are going to cover the combo box including how to get the data about the selected item and how to cascade dropdowns.
Full courses: www.iamtimcorey.com/
Source Code: leadmagnets.app/?Resource=WPF...
Patreon: / iamtimcorey
Newsletter signup: signup.iamtimcorey.com/
0:00 - Intro
1:17 - Prerequisite
2:04 - Demo app overview
8:14 - ComBobox: creating, data binding and data displaying
11:44 - Binding with Caliburn Micro
13:41 - Data Template: StackPanel
16:13 - Selected item: Display data
20:40 - Selected item: Display data dropdown (nested data)
23:49 - Selected item: Displaying data from nested dropdown
32:24 - Summary
34:51 - Concluding remarks
Thanks to Ralfs HBK for the chapter breakdown

Пікірлер: 173
5 жыл бұрын
Thanks Tim, it's help me a lot to understand how fun is to learn WPF!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Great!
@n9434178
@n9434178 5 жыл бұрын
Thanks Tim! Great video as always.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Thanks!
@nhanth
@nhanth 5 жыл бұрын
Really looking video about datagridview and Dataset. :D. You are the best Tim.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Thanks
@paichi81
@paichi81 4 жыл бұрын
I'm Japanese and I'm not very good at English. Thanks for the explanation of MVVM. It's a gentle narrative, and the automatic KZbin translation works well. I was struggling with the lack of material on Caliburn.Micro, but the video helped me out. It is.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I am glad it was helpful.
@roko567
@roko567 5 жыл бұрын
Yesss!! I've been looking forward to this video! DataGrid next, pretty please?
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
It is coming soon.
@colin-campbell
@colin-campbell 5 жыл бұрын
Oh god I’ve been so looking forward to a toolbox overview! I’m such a nerd...
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
lol
@tharindusenevirathna7367
@tharindusenevirathna7367 5 жыл бұрын
Very Clear and Understandable ...
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Great!
@ABMedia83
@ABMedia83 Жыл бұрын
Great video, I use my own MVVM Framework. MVVM saves a lot of time when it closes to the ComboBox. I almost never set my Items in XAML, I almost always use DataContext and ItemsSource.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thanks for sharing!
@pierrebielen7143
@pierrebielen7143 3 жыл бұрын
Very nice, thanks
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Thanks for watching
@LuxTheKarma
@LuxTheKarma 5 жыл бұрын
i love your videos so much please keep going
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Will do.
@vinuhosanagar1
@vinuhosanagar1 5 жыл бұрын
That's been very useful video. Thank you Next Datagrid please.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
It is coming soon.
@olivin8937
@olivin8937 Жыл бұрын
Ha, @25:55 was exactly what I was doing, with my quest for answers leading here. Ended up binding SelectedItem to a property and calling methods from its setter (MvvmCross).
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thanks for sharing!
@ChrisJarzynka
@ChrisJarzynka 5 жыл бұрын
Tim: long time viewer first time poster. I love your channel and the quality of the videos you put out. The fact that you're able to release videos so quickly at this quality is amazing! You originally turned me on to Caliburn.Micro with your video from 2017. I was a bit surprised when you were able to use POCO items to feed a BindableCollection. I was always under the impression that my data classes had to implement NotifyOfPropertyChange on their members as full properties. Did I miss something fundamental in the Caliburn.Micro documentation? Since my app uses tabs I'm using CM from a Bootstrapper class. Does this make any difference? I can't see why it would. BTW, I think you should get 5% of my future software sales - your tutorials have been an amazing help!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
The NotifyOfPropertyChange is baked into the CM libraries. Also, the BindableCollection also fires off notifications when items change.
@ivandrofly
@ivandrofly 2 жыл бұрын
19:00 thanks for the caliber-micro thing
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@SpesEtFides111
@SpesEtFides111 5 жыл бұрын
Tim, you rock! I'm working on a WPF app where I believe I have to use a grid for dynamically added controls (textboxes and checkboxes) and data grid to store the data entered in those controls. When I say "dynamically added" I mean a situation when user can add another row of textboxes and checkboxes to the window by clicking "Add row" or "+" button. That'd be very helpful if you could shed some light on the aspects of creating something like that.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I believe I already have that scenario covered in an upcoming WPF video in this series. Thanks for the suggestion.
@SpesEtFides111
@SpesEtFides111 5 жыл бұрын
Looking forward to watching it! Thank you!
@PatricSjoeoe
@PatricSjoeoe 5 жыл бұрын
Hi Tim! Good tutorials as usual! Can you please put all of your wpf material in its own playlist? :)
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
That is coming soon. Thanks for the suggestion.
@mohammadranjbaran1897
@mohammadranjbaran1897 2 жыл бұрын
Thanks a lot.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@cesarpinto1989
@cesarpinto1989 5 жыл бұрын
Hi Tim, first of all thank you for your content. I´ve been watching your videos and they are very helpful. Now, I´ve followed this method you show on this video and all works well. I have 2 combo boxes, the first with the manufactor of a product and the second with brands of that manufactor. So when i choose the manufactor on the first combo box, the second Combobox only shows their brands. That works great! Now the problem is that I pré-populate the Selected Items. So what i would expect is that when i load the data both combo boxes should show the correspondent information. Well, the first combo box works fine, it shows the manufactor, but the second one is always empty. One thing i´ve noticed, after debugging, was that the property of the Selected Item for the Brand is populated before the combo boxes are loaded on screen, but right after they show up the Selected Item turns null. It´s been days trying solving this issue. Can you, or someone here, help me with this? I am also using Caliburn Micro but instead of WTF I´m using UWP. Thank you so much!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I'm wondering if the event that triggers the second combo box to be filled is getting fired when the Manufacturer combo box has the selected item filled. You might need to suspend that event if you are in the process of loading (like creating a variable called IsLoading that is set to true before the data gets populated and is set to false only after everything is loaded. Then only fire an event if the IsLoading is false.)
@shawnmofid7131
@shawnmofid7131 5 жыл бұрын
Tim, thanks again. I learned a lot. I did read some of the FCL documentation to get up to speed with what binding really meant and learn more about some of the tags we used like combobox, listbox, DataTemplate etc. I did run into a question: and did not give me the same result. I think you said x:Name and SelectedItem are similar or the same. When I used SelectedItem={Binding ...} method I did not get any addresses.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Combo Boxes are a bit different. You bind the list and then you bind the selected item instead of just binding the Text on a TextBox.
@shawnmofid7131
@shawnmofid7131 5 жыл бұрын
@@IAmTimCorey Thanks. One more question please. Is there a name for closing method vs. self-closing and what is the difference in terms of when we use one vs. the other please?
@amasoumi
@amasoumi 5 жыл бұрын
gr8 video!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Thank you!
@RalfsBalodis
@RalfsBalodis 3 жыл бұрын
0:00 - Intro 1:17 - Prerequisite 2:04 - Demo app overview 8:14 - ComBobox: creating, data binding and data displaying 11:44 - Binding with Caliburn Micro 13:41 - Data Template: StackPanel 16:13 - Selected item: Display data 20:40 - Selected item: Display data dropdown (nested data) 23:49 - Selected item: Displaying data from nested dropdown 32:24 - Summary 34:51 - Concluding remarks
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Thank you sir!
@okitkin
@okitkin 7 ай бұрын
Thank you !))
@IAmTimCorey
@IAmTimCorey 7 ай бұрын
You are welcome.
@prashanthCse
@prashanthCse Жыл бұрын
i need a comboox filter while typing and using to select arrows in wpf c#
@mihaimyh
@mihaimyh 5 жыл бұрын
Hi Tim, I really appreciate your videos, learned alot from you. I would like to ask you if we can bind in the same way the Content property of a CheckBox. will work?
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Yep. I'm not 100% on the syntax (thank goodness for Intellisense) but the concept is correct.
@cosmix1986
@cosmix1986 4 жыл бұрын
Hi Tim, first of all many thanks for all your effort you put into the videos. I have never followed such a well-explained series of learning videos. I have a quick question which most likely is easy to answer for you. How would a binding look like if you would like to place a combobox twice, both refering to the same property? I know that it somehow must work with doing a manual binding. That's how you already explained it for textblocks. But how would you do this for a combobox? Thanks for your help. Keep you publishing new videos :-).
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
The concept is basically the same. Instead of name binding, you manually bind the data to your property.
@karolderbin2767
@karolderbin2767 2 жыл бұрын
I did everything just like in your movie. When binding data to the name People, I have the warning No DataContext found for Binding People. I looked through all the code again, but combo box is still empty.
@bishopprime2585
@bishopprime2585 4 жыл бұрын
I have enjoyed your videos, they have been a great help. How would you "unselect" or "reset" a selected item in a combobox? In other words, the equivalent of doing selected index equals to negative one? Any help would be greatly appreciated.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Change the property value in the ViewModel.
@mastercompuk
@mastercompuk 5 жыл бұрын
Good tutorial as always. Can you do one more how to bind enum to combobox a still be able to save to DB as int and display in combobox as display name of enum. What is the best practice ? Thank you.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I will add it to the list. Thanks for the suggestion.
@anycolouryoulike9160
@anycolouryoulike9160 4 жыл бұрын
Is it ok to put code behind the view to deal with events? click, keydown etc. I was trying to filter the items inside my combobox using events (like keydown), but then I found a better way using only NotifyOnPropertyChanged and a new Property to hold user input.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
If you are using MVVM then you want to put your filter code in the ViewModel and then bind to the keydown event (or whatever you want) to trigger the filter (if that is even necessary - I doubt it is since you can just filter based upon the property and since it changes, the filter changes).
@matiascatanzariti1195
@matiascatanzariti1195 5 жыл бұрын
Hi Tim, thanks for another great video. Maybe it is not the right place for these questions, I apologize for that, but I have two and I couldn't find a better place :). First, I need to learn more about the "organisation" of an application, how to design models, view and so on, I'm kind of new to MVVM. Do you have any course you could recommend to me? Is "Tournament Tracker Add-on: WPF with MVVM User Interface" the right one for this? And second, do you have any video or any blog talking about the power of C# vs VB in .NET? I have googled a lot but in most of the cases it seems that there are not great differences. I would like to have more arguments about that. Many thanks. Matías.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
The Tournament Tracker Add-on course that covers WPF will show you a practical example of MVVM in action. On this channel, I have a playlist of WPF videos, most of which use or explain MVVM. Those two options in combination will be a good way to learn MVVM. As for C# vs VB.NET, I don't have a video on it but here are the basics: VB.NET was created to transition VB6 developers over to the .NET platform (I was one of them). It was a stepping stone. The primary focus of Microsoft, and of the world in general, is on C#. So while VB.NET continues to tag along, it isn't as good of a solution simply because of support. If you search for an example of something on the Internet, the example will be in C# 99 times out of 100. If you watch a tutorial, it will almost certainly be in C#. Even Microsoft's documentation tends to only add on VB.NET occasionally. So while VB.NET was a great way for VB6 developers to ease into .NET development, it isn't a great option for your long-term language.
@therealguy12378
@therealguy12378 5 жыл бұрын
Hi Tim, thanks for the video. It is informative even almost a 1 year ago. I have question regarding the 'Models' folder. Is the WPFDemoUI's 'Models' folder compulsory(due to naming convention) or even useful if compared to DemoLibrary's 'Models' folder? To me, it seems it is replacable by DemoLibrary's 'Models' folder. Compared to 'Views' and 'ViewModels' folder which have strong relationship, WPFDemoUI's 'Models' folder seems can be called from other Library Class.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Yes, the Models folder should remain in the UI. It isn't technically needed for MVVM but it should be there. The issue is that Models in your library can be useful until you need to add UI elements to them (decorators such as Required or MinLength, etc.) Then you need to have your Models in your UI that are close to what you have in your library. I came across this issue in the TimCo Retail Manager series.
@pablogiaco4842
@pablogiaco4842 4 жыл бұрын
Hi! i have a question a bit outside the scope of this video, but is very related. In the constructor of ShellViewModel (7:05) you called a method (da.GetPeople()) for getting a BindableCollection of People from a DataAccess object (da). If there were a chance that this method threw an exception, what would be the best way to handle it? A Try Catch block inside the constructor? As always, thank you so much for your excelent videos!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Correct.
@mihaimyh
@mihaimyh 5 жыл бұрын
How should I implementent the change of text in the TextBlock if the CheckBox will be checked? Let's say TextBlock is displaying the selection of the combobox, but after checking the checkbox, the TextBlock text will change to any other property of the SelectedPerson. I am really struggling with this.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Maybe instead of trying to change the binding of a TextBox, you could have two TextBoxes that occupy the same space. Hide or show each based upon the value of the Checkbox. Then it appears as though the box changes bindings but it is actually two different boxes.
@muhanad102
@muhanad102 4 жыл бұрын
Hello Tim is there a way I change the ComboBox behavior to not capture mouse? Every time the dropdown is open and I try to click something outside the Checkbox/dropdown, it closes the dropdown and prevents the clicked control from receiving the mouse click!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Interesting question. You could put something in the click action for the cell around the checkbox that toggles the checkbox when clicked (so the whole cell acts like the checkbox).
@Joel4JC
@Joel4JC 4 жыл бұрын
Tim, at 16:54 you are typing in variable name _selectedPerson and when you hit the tab key it changes to the suggested variable name personModel, is there a way to get it to accept the variable name you are typing in and not the suggested name when you hit the tab key? It looks like you got it to work the first time at 28:48 when you typed in _selectedAddress. I've been trying to figure this out ever since I saw this video for the first time and I've searched all over the internet and cannot find a solution.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Hit escape instead of tab.
@Aaraoo
@Aaraoo 5 жыл бұрын
Hi Tim, I'm Trying to use this knowledge to do my own script with interface to PowerSehell, but i have some problem to show what i have in combobox concatenated in a txtblock, do you know anything about?
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Not sure what you are trying to do, sorry. I do have a video on how to work with PowerShell in C# coming soon (about a month or so).
@KTMFerr
@KTMFerr 5 жыл бұрын
How could we change the SelectedItem from the back code? On your example we do not want the the user to have to click the Addresses Combobox to select the first result. The first or default address for that Person Model should be preselected by the code.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
When you populate the list in the VM, take the first value and put it in the property that serves as the selected item.
@maksa83
@maksa83 4 жыл бұрын
Hi Tim - thank you for yet another great video! Out of the box, I've got an error 'The name "Bootstrapper" does not exist in the namespace "clr-namespace:WPFDemoUI" ' on the line of App.xaml Reinstalling Caliburn Micro, restarting Visual Studio did not help. Any ideas?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Did you create the Bootstrapper class? Also, did you use the version of Caliburn Micro I did? Later versions changed some things.
@maksa83
@maksa83 4 жыл бұрын
@@IAmTimCorey re-building the WPFDemoUI project solved the issue for me. I am using Caliburn.Micro v3.2.0 - works like a charm on this and preceding WPF video-tutorial projects )
@marcosrod7260
@marcosrod7260 2 жыл бұрын
Is there a way to offset the string a bit to the right once it is selected from the dropdown?
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Yep, although I don't have an example to show you.
@sirpierozek
@sirpierozek Жыл бұрын
I have a question, how to change the color of a control (Backgroud) in WPF and control the color in c# code (in xaml I know how to do it)?
@Techniker357
@Techniker357 Жыл бұрын
Xaml: cs: myButton.Background = new SolidColorBrush(Colors.Red); make sure you have: using System.Windows.Media; namespace
@hiromijorge400
@hiromijorge400 3 жыл бұрын
hi and thanks for the tutorial. im curious about how we store the SelectedItem and Show it to the console, thanks and god bless you.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
We are putting the SelectedItem into the SelectedPerson object. Then, when we want to get the value for SelectedItem, we just look in the SelectedPerson object (line 18 at 18:16).
@demonKing10
@demonKing10 5 жыл бұрын
How are you binding your textblock to display value selected in comboBox?
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
It has been a while but I believe I'm binding the TextBlock to the SelectedItem from the ComboBox.
@pablogiaco4842
@pablogiaco4842 4 жыл бұрын
And here goes another one, hope you dont mind. What if i want that method da.GetPeople() to be async? Let say i need that data there when the windows load, and it comes from a API. I saw a bit of a debate on the internet regarding to this. I tried Stephen Cleary's library Async.ex in order to do Asynchronous Initialization but the nuget package didnt work, maybe i should try again. But besides that i would really like to know your opinion about this topic. Thanks!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
In this case, we are doing sample data access so there is no need for async (actually, it would be a bad thing since it would add overhead without adding any benefits). However, when you are doing real data access, you would make that call asynchronous. For example, Dapper has the option to make calls async. So QueryAsync instead of Query.
@frazanwer403
@frazanwer403 4 жыл бұрын
how can a product lookup work in datagrid mvvm using caliburn when click a cell in datagrid a lookup opens for product to pick and add it back to datagrid and show its price i have a form where i want this to work but i am unable to do it can u do a video on such task
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I will add it to the list. Thanks for the suggestion.
@karatekid559
@karatekid559 5 жыл бұрын
Hello Tim I'm wondering why did you update the People BindableCollection by putting it in a constructor? I know other times you use just properties with backing fields and use NotifyOfPropertyChange. Sorry I'm totally new to MVVM and Caliburn and I'm having a hard time understanding this stuff
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I'm not sure what you mean by updating it in the constructor. Can you explain a bit more about what you are asking about?
@karatekid559
@karatekid559 5 жыл бұрын
​@@IAmTimCorey I'm sorry I should have been more specific. However, I think I understand now. Am I correct when I say that BindableCollection kind of does the same thing as NotifyOfPropertyChange?
@spinazspinaz
@spinazspinaz 5 жыл бұрын
Tim, why do you never call NotifyOfPropertyChange in setter of BindableCollection? Is it something related to the fact that this thing implements INotifyPropertyChanged interface?
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
BindableCollection has the notifications built in.
@SuperChristianMiiworld
@SuperChristianMiiworld 4 жыл бұрын
Question: I have a list of people extracted from my own database in my comboBox listed in my program however, when I click on a name in the comboBox let's say "John Doe" or "James Deen", every time I do that the ComboBox shows me nothing. An empty box. Does not display their name. How can I make it so that when I select a name it sticks to the name instead of giving me an empty box? Really love your content. Very informative.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Does the technique I showed you in this video not work? It should show you the name like it did for me.
@SuperChristianMiiworld
@SuperChristianMiiworld 4 жыл бұрын
@@IAmTimCorey Well, my project is different from the one on your video. What I did so far was write a database on SQL Server, create my WPF form, created a ComboBox and inside my ComboBox I typed in a method that would take the SQL data set from SQL Server and populate it into the ComboBox. I also wrote a code that pushed any new entry into the SQL database and update the ComboBox with the updated data. Is there a way I can share to you what I've got? I'd post it here but I'm a very private person lol.
@sachinjoshi7792
@sachinjoshi7792 5 жыл бұрын
Pls suggest me how to bind combobox value with tables values and print in console with select combobox value
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I'm not sure what you mean by binding a combo box with table values. If you mean from a database, that is essentially what we are doing here. I don't like the concept of directly tying it to the database table, because that leaves open a connection, ties you tightly to the database, and generally ignores any layering in your application. As for printing to the console, we don't really have a console in WPF. You can technically do it but only a developer can see it. This video shows you how to get the selected value, though, so you should be able to put the rest of the pieces together.
@VinuP2023
@VinuP2023 5 жыл бұрын
Hello Sir, wound you please tell me How can I achieve Auto suggest kind of functionality in Combobox. I tried IsEditable=true, Readonly=false. If I type 'Jo' in combobox drop down, list of names containing Jo like Joe Rege, Regan Joe, Jordan have to appear from list of bound data. Thanks much
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
The simplest thing would probably to have an event fire when the user starts typing. The event could filter the list based upon what is typed.
@BoyOfTheFuture4987
@BoyOfTheFuture4987 5 жыл бұрын
Please make on with datagrid with itemssourcre and has a total row and a title of the table.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
These types of scenarios will be covered in future videos in this series.
@josegregoriomoyaurpin3949
@josegregoriomoyaurpin3949 5 жыл бұрын
Hi tim, great job, how can do this without caliburn lib... thanks!
@josegregoriomoyaurpin3949
@josegregoriomoyaurpin3949 5 жыл бұрын
Nothing that does, simply implement the Notify class and voila, great job tim, I follow closely your tutorials and tips.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
You can do binding without Caliburn Micro. It just isn't as easy.
@LanDiEvil
@LanDiEvil 5 жыл бұрын
How do I make it do IoT with full batteries and More powerful class.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
That's really not in the scope of this channel yet.
@suriyadexter9674
@suriyadexter9674 4 жыл бұрын
how to list the selected item in the data grid .. instead in the text box?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I have a video on how to work with the datagrid here: kzbin.info/www/bejne/sKfcgoGrqrmkodU
@jeremyflowers8908
@jeremyflowers8908 5 жыл бұрын
@18:01 Should the Notify not happen after the set? LOL: Just before 20:22 it got you!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Yep, I usually forget that at least once.
@andreass7388
@andreass7388 5 жыл бұрын
Hi Tim, you set the binding by ItemsSource="{Binding pathName}" (or by x:Name="propertyName), but I can't figure out, how the binding source is set... I would be pleased, if you could explain the mechanisms behind different ways of defining the binding source (and binding path). And as I mentioned in another comment, it would be so great, if you could do a video on implementing all these binding examples in code behind, just to understand what really is going on under-the-hood. At the moment I'm working my ass of, trying to understand the binding mechanisms, but I already lost the overview. Especially binding a DataGrid with different kinds of columns, setting up in code behind doesn't work as I want to have it. So that would be awesome. Thanks for your efforts.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I can see what I can do. Basically, these are wired up by Caliburn Micro directly. Further explanation will come in a future video, if I can fit it in somewhere.
@andreass7388
@andreass7388 5 жыл бұрын
@@IAmTimCorey that would be awesome.
@InsidiousRat
@InsidiousRat 5 жыл бұрын
Why do we sometimes write {Binding ...} and sometimes {Binding Path="..."}? What is the difference?
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
There are slight differences: stackoverflow.com/questions/5488014/are-binding-path-and-binding-really-equal
@theofficialamt6626
@theofficialamt6626 3 жыл бұрын
Can you make a video Visual Studio Windows Form on saving and loading multiple Comboboxes whatever the user selects in each combobox they can click a button to save to a specific location and have a load button to find the exact file and it will populate each combobox they changed.
@theofficialamt6626
@theofficialamt6626 3 жыл бұрын
Been searching for a few days now.
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
That is pretty specific and unique. Tim strives to teach viewers broad skills that are adaptable in a multitude of situations. It is unlikely he will attempt to resolve you specific project.
@theofficialamt6626
@theofficialamt6626 3 жыл бұрын
@@tomthelestaff-iamtimcorey7597 k.
@andrewparker6877
@andrewparker6877 3 жыл бұрын
How does the Person know which Addresses are associated with it, where is the link?
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
In this demo, we add AddressModel class objects to the PersonModel class directly. So the PersonModel contains the associated AddressModels associated with it.
@_samirdahal
@_samirdahal 4 жыл бұрын
Out Of The Box: Will you release the course on Xamarin Form as well here on KZbin?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
The course will only be on IAmTimCorey.com but I will release videos on Xamarin Forms on this channel.
@_samirdahal
@_samirdahal 4 жыл бұрын
@@IAmTimCorey That means a lot, thank you so much!
@jakovkonta5450
@jakovkonta5450 4 жыл бұрын
Hi Tim, How do you display comboBox name? I would be nice to "see" what comboBox holds, especially when there is more of them on a form. So lets say that I want to see a "People" on a comboBox. I know I can solve a problem by putting a textBlock saying "People" in front of a comboBox filled with people, but what about having a both things on same box? :) Thanks for tutorial, great content!!!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Not sure what you mean by both on one box.
@jakovkonta5450
@jakovkonta5450 4 жыл бұрын
@@IAmTimCorey Well when I start the application I would like to see "People" on a comboBox so that the user knows what that comboBox holds. So that is not an item in a comboBox just an initial value set on comboBox.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
OK, got it. You can do something like that by building it as a custom control (which is fairly easy in WPF).
@badartech8343
@badartech8343 5 жыл бұрын
Hi Tim, I love your videos, and learnt alot from your stuff. I have a Question regarding image source binding from string path (the image is stored in image folder of my project as resource) However, when i apply the source binding, it ends up showing nothing! Below is the code provided.. code (xaml):
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
In code, it would look something like this: screenImage.Source = new BitmapImage(new Uri(imageFiles[currentImage], UriKind.Absolute)); In a binding, it would look more like this: stackoverflow.com/a/2068983/733798
@paulopraca6197
@paulopraca6197 4 жыл бұрын
I can't download the code. Thanks for your video
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Send me an email at tim@iamtimcorey.com and let me know which one is giving you an issue. Also, check your spam folder.
@spinazspinaz
@spinazspinaz 5 жыл бұрын
hy Tim, in other video you used Mode=OneWayToSource. But here you don't. Why?
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Because in that video I wanted updates to flow one way. In this video I wanted them to go both ways.
@abu_store_smart_tech
@abu_store_smart_tech Жыл бұрын
gap yo'q 👍👍👍
@IAmTimCorey
@IAmTimCorey Жыл бұрын
👍🏻
@LanDiEvil
@LanDiEvil 5 жыл бұрын
Whats a public static superdooper class mean? Bc that's what mine says. Must be a better version I paid $10,000 dollars for my laptop so its heaps better than everybody else's. How do I get into the code section of this laptop?
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Maybe you should stay tuned for my Foundation in C# video that is coming out soon. It sounds like you need to start at the beginning of C#. This video is definitely not the place to start. Join my mailing list so you hear when the Foundation in C# course modules are released.
@LanDiEvil
@LanDiEvil 5 жыл бұрын
I'm just talking smack bro. This video is just what the Dr ordered. I've been trying to figure out the simplest method of setting ItemsPanelTemplate of a ListView using either DataTemplateSelector, VisualStateManager or a click event +='d on a void. Hoping to find all the answers in this video.
@LanDiEvil
@LanDiEvil 5 жыл бұрын
Whats a data?
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Data is any information you want to store or show. Like name, email address, etc.
@RafaelSantos-hg7jh
@RafaelSantos-hg7jh 5 жыл бұрын
Still entreprise projects with WPF ?
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
You can use WPF with enterprise projects, but you can also use them for small personal projects or anything in between.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Actually, Visual Studio was built with Visual Studio in WPF for the UI. The only HTML in it that I'm aware of is the start page. Discord was built with Electron so it is JavaScript/HTML/CSS.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Oh, sorry, I misread that. Yep, VSCode is written in Electron for cross platform compatibility.
@barbaraerdec9388
@barbaraerdec9388 2 жыл бұрын
a havea problem with ActivateItem ---doesnt exist
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are probably using the 4.x version of the NuGet package for Caliburn Micro instead of a 3.x version. In 4.x, they made all of the calls Async (so ActivateItemAsync exists). It will change how the code works, though, so unless you feel confident in knowing how to translate what I do to async, just roll your version of Caliburn Micro back to the latest 3.x version and you will be fine.
@n9434178
@n9434178 5 жыл бұрын
Hi Tim, I came back to this video hoping to find an answer to the question how to bind an object which has numerical values for some properties, but for the user those numerical values need to be converted in readable text in the View. I would like to use enums with descriptions (see eg: stackoverflow.com/questions/2650080/how-to-get-c-sharp-enum-description-from-value) in my 'DemoLibrary'. What if the IsAlive property of the Person model had not been of type Boolean but of type Integer and we had an enum like this: public enum IsAliveOrDead { [Description("This person is alive")] Alive = 1, [Description("This person has died.")] Dead = 2, [Description("It is unknown if this person is alive")] Unknown = 3 } I would like to store the numerical value in the database, but show the description in the View. There are a lot websites trying to cover this topic, but so far I have not come across an example that uses caliburn micro and mvvm and more importantly is as clear as your videos typically are. Perhaps you could consider to cover this topic in a future video.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I can definitely add that to the suggestion list.
@ZoidbergForPresident
@ZoidbergForPresident 5 жыл бұрын
MVVM?
@Bloodthirst
@Bloodthirst 5 жыл бұрын
Model - View - ViewModel , a very effetive way to write you're business logic once and make reusable in many types of projects (WPF , Xamarin , etc)
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Correct. MVVM is a user interface design pattern that allows us to separate our displays from our data (like MVC in ASP.NET). It allows us to create less form-specific code so that it is easier for us to replace a form down the road without rewriting our UI code (data binding, event handlers, etc.)
@grantsamson2384
@grantsamson2384 4 жыл бұрын
Warning to anyone testing out combo boxes: when you're using NotifyOfPropertyChange, make sure you're pointing to the property and not the underlying field. Making that mistake is... painful.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Thanks for sharing.
@vladimirmilatovic
@vladimirmilatovic 5 жыл бұрын
Hi Tim, I back to this video to find out how you populate addresses for person. My question is how would you do that with dapper? But, not for only one person, how you will get all persons and get all addresses for them? I found this article on web (section: A parent object with its child objects) www.tritac.com/blog/dappernet-by-example/ I would like to see your solution. I couldn't test this code because I couldn't find this lookup.TryGetValue(). I install System.Linq package but still I don't get this method. Maybe you can make some advance video about Dapper. Thanks.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I have some advanced Dapper videos coming soon that should answer your question.
@vladimirmilatovic
@vladimirmilatovic 5 жыл бұрын
@@IAmTimCorey Hi Tim, Thanks for your answer. Never enough new subjects. In mean time I found WPF Dialogs that can be very interesting for new video. I found few examples on KZbin but no one explain what and why they are doing. Thanks.
@LuigiZambetti
@LuigiZambetti 5 жыл бұрын
But WPF is still used nowadays?
@NBGTFO
@NBGTFO 5 жыл бұрын
People still use COBOL. Why wouldn't they use WPF? Plus Microsoft is working on .Net Core 3.0 which will have applications in WPF and Windows Forms (yes, people still use Windows Forms).
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Correct. WPF is the top-tier desktop application from Microsoft unless you are able to do UWP applications (most organizations are not because of the operating system requirements). Actually, the most common desktop user interface in businesses still seems to be WinForms because they just work and they are easy. Microsoft has committed to supporting WPF and WinForms for a long time into the future.
@noralkuhlmann750
@noralkuhlmann750 2 жыл бұрын
Great videos BUT have videos WITHOUT 3rd party references, like C.M, first. 😮‍💨
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thanks for the suggestion.
@Yelonek1986
@Yelonek1986 Жыл бұрын
Why? That is the most infuriating thing about WPF. Why do I have to implement an object with INotifyPropertyChanged? WTF? Why do I need to implement ICommand? This should be part of the standard library. Millions of programmers have to implement these stupid objects first. They will not get it on the first try and there will be no tests for it. What a waste of time!
WPF Controls with MVVM: ItemsControl
33:34
IAmTimCorey
Рет қаралды 83 М.
WPF in C# with MVVM using Caliburn Micro
1:23:30
IAmTimCorey
Рет қаралды 362 М.
A teacher captured the cutest moment at the nursery #shorts
00:33
Fabiosa Stories
Рет қаралды 55 МЛН
Задержи дыхание дольше всех!
00:42
Аришнев
Рет қаралды 3,8 МЛН
CHOCKY MILK.. 🤣 #shorts
00:20
Savage Vlogs
Рет қаралды 14 МЛН
Inside Out Babies (Inside Out Animation)
00:21
FASH
Рет қаралды 23 МЛН
The Basics of Data Binding in WPF
20:53
Tactic Devs
Рет қаралды 38 М.
C#/WPF - Learning the DataGrid
1:42:38
Kevin Bost
Рет қаралды 10 М.
WPF Controls with MVVM: DataGrid
24:59
IAmTimCorey
Рет қаралды 172 М.
WPF Controls: Learn basic WPF controls in C#
29:48
IAmTimCorey
Рет қаралды 178 М.
Switching Between Multiple Views in MVVM - EASY WPF (.NET CORE)
12:29
C# WPF Tutorial #20 - Reusable Style Resources
11:11
Kampa Plays
Рет қаралды 13 М.
Picking a New MVVM Framework - Moving from Caliburn Micro
1:27:32
IAmTimCorey
Рет қаралды 98 М.
A teacher captured the cutest moment at the nursery #shorts
00:33
Fabiosa Stories
Рет қаралды 55 МЛН