I spent a ton of time trying to figure out the ins and outs with the newer Win UI3. There was no beginner-friendly resources, especially ones that focussed more on the 'how' and 'why' instead of 'what' when it comes to XAML. I'm so glad I took a step back to WPF, as your tutorials are very comprehensive and put many of the principles into perspective. A few years late, but I just wanted to say thank you so much!
0:00 - Intro 0:29 - ComboBox 2:53 - ComBobox Data: Creating a List of T 4:06 - ComBobox Data: Assign a List of T to the ComboBox and display property of T 9:37 - Image 12:18 - MediaElement 14:22 - StackPanel 18:22 - WrapPanel 20:44 - ScrollViewer 23:05 - StackPanel inside ComboBox 26:18 - Item Parent and placement 28:20 - Summary and concluding remarks
played with WrapPanel Inside the ScrollViewer, when you disable the default VerticalscrollBarVisibility="Visible" to Disable, the WrapPanel with Orientation="Vertical" works just fine again :) if you think about it, as long as you can scroll, the WrapPanel dont need to Wrap, first when the Scrolling in Vertical-Side is disabled, it's need to wrap and does so
If somebody has a problem with playing video ( 13:15 ) there is a solution: 1. Right click your video file in the solution explorer and chose "properties". 2. Make sure Build Action is set to "Content". 3. Make sure Copy to output is set to "Copy Always" or "Copy if Newer".
You are a great teacher i wish we had teachers like you in my college, As Indian's we proud of our IT sector but our institute's lake good teachers, love from India
Hello mr. Corey, I might be late to the party few years. Just realised the MediaElement is media and video probably because since I didnt have video, I was able to add MP4, which doesnt contain any image, just sound. Might be because you can add more elements than just video. And by the way, thanks for this tutorial ! The way you explain things is awesome :)
I just clicked the Like button , but where is the love button :D!! very good video. I'm working with WPF and MVVM pattern also for a work project, but with this videos I'm filling up my gaps, I really trust that the tutorial will be more complex (the future tutorials) so thanks for your time. !
Man WRAPPANEL and other controls in WPF we take it for granted, just imagine implementing that in C++ all those manual resizing and re renderings. All of that math you have to perform manually, I'm glad I am a C# programmer.
Suggestion: Admittedly, this is 'young grasshopper' opining to 'Master Yoda' (and mixing about 3 generations of metaphors along the way...), but may I suggest that to give students a fuller understanding of ComboBoxes, that you start by saying something like "There are 2 ways to populate a ComboBox: Statically and dynamically. Statically is just like adding a Master Card , etc for each option. Pretty simple. Now the really interesting and more typical is a dynamic, data-driven one like this PEOPLE example I'm going to show you...". One on-going disappointment I have with a LOT of training courses is that they often show only one way (like the above), but do not even allude to any other options, misleading the student to think that there is no other way than the example shown. Thanks for listening :)
I hear you and I try to do that when I think it is important. However, in this case I'm not really a fan of encouraging people to add things to a combo box statically. You could argue that some things never change but I've been around long enough to know that isn't really true. Even if you had days of the week in the box, at some point someone is going to want to change those to abbreviations or they are going to want to localize them. Either way, you now have to open your application and recompile it.
6:30 three days i ve been stuck on this , tried all sorts of shit to display the fkin names on list box , then i figured it out by using linq i sorted lists.Name option, then when i tried to deleted the particular item i coudnt able to get the id of that particular item,. Engneering is a hard if not guided in a right way , thanks for his sir...i will watch all of your videos and siply write a comment , thats all i can do atm
I cannot seem to find anyone with a video on how to instantiate a controltemplate or usercontrol in code behind. This is totally needed for cases when data is driving how many controls you need at run time, for example an image grid where you load according to how many pics returned by a sql statement, etc.
Hi Tim, great tutorial as always. I started to make simple classic games in C# like snake, tetris, pong etc.I have already made Snake in Windows Forms. Now I want to try WPF, so I have few questions. 1.In WF I used the pictureBox control and the Graphics class to draw shapes. What should I use in WPF ? 2. How to correctly center a form on different screen resolutions? When I use the property WindowStartupLocation = "CenterScreen", it works only for resolutions greater than specified form size, otherwise it's cut vertically.
Classic games in WPF are much more possible in WPF. Unlike WinForms, where you were pushing the edge to get anything to work, WPF is designed for movement and drawing. In fact, all of the controls have the ability to animate and change built-in. I'd start by checking out this article: docs.microsoft.com/en-us/dotnet/framework/wpf/graphics-multimedia/animation-overview Then I'd look at this article: www.c-sharpcorner.com/UploadFile/52f7b2/wormrace-using-wpf-animations/ Those two should get you started not just in drawing the shapes but in animating the movement. As for question two, I think you are mostly at your solution. I would just do a check on startup to see what the screen resolution is, and if it is smaller than the form, just maximize the form. Then it will take the available space, and even though it isn't as much as you want, at least you won't have any off-screen issues. Then you just need to make sure your form can run at the smaller size without an issue.
Thanks for the tips. PS: If someone had a problem with moving shapes using the Canvas.SetTop (Left, Right ...) method and the timer tick event. You must first initialize the Top value for shape in C# or XAML XAML: Canvas.Top = "0" C#: Canvas.SetTop (shape, 0); Then you can use this in your timer tick Canvas.SetTop (shape, Canvas.GetTop (shape) + value); It took me a few hours to get it working .... I should use WPF animation :))
Hey, you make amazing videos! I wanted to know if you could recommend what I should do about this. I'm wanting to make an IPTV m3u channel list application, which lists channels with a timeline of the shows that premiere at a certain time. Normally there are about 1500+ channels and even more shows. Do you know any good way to show this data without crashing and lagging the whole window? I tried this in WinForms and it is just a complete lag disaster. I wanted to make a list menu on the left side, and when you go to click the item it brings up the channel information on the right. Thank you Tim! Or if you have another suggestion of how I should show this data?
@@tomthelestaff-iamtimcorey7597 I haven't yet watched them all, but on scrubbing through them I see no use of an embedded web browser tool. Am I missing something?
Hi Tim, Great videos I must say! is it possible to make a video where you, take the user input from the textboxes and saves them in a .txt file? I'm trying to make a simple string creator tool in WPF. And alså with the combo boxes. How is it possible to, show the same as you are doing in the video, but where it reads from a .txt file instead. Hope you understand what I mean. I'm pretty new to programming. I'm looking at your videos to learn, you are a great teacher! :D
sorry for this late question, but maybe i am lucky :) . the DataTemplate, its it possible in VS to save it as a "external file" and just refer to it instead. So i can have seperate files whit difrent templates so its easyer to work whit and se whats happening :) sorry about the bad Eng not my first lang. Thx
My Foundation in C# course series is the best place to start. It will give you a firm understanding of all of C# and it will also cover the start of WPF. That way you are ready to progress to more in-depth learning on WPF. Here is a video that shows you more about how to get started: ruclips.net/video/LUv20QxXjfw/видео.html
Hello Tim, I'd like to bind Radiobuttons to a boolean but I read this: The radio button control has a known issue with data binding. If you bind the IsChecked property to a boolean and check the RadioButton, the value gets True. But when you check another RadioButton, the databound value still remains true. Would you say that is still the case and one needs to make a workaround for it?
If you are doing manual binding, here is a solution: www.wpftutorial.net/RadioButton.html If you are using Caliburn Micro, it is even easier: stackoverflow.com/questions/14341484/set-radiobutton-checked-in-code-with-caliburn-micro
hey corey, I hope youll reply. So I was following your steps and then I had a problem in the mediaelement part. It doesnt show in the editor view as well as in runtime. I tried dragging it into the form but an error message popped up "The media file (filepath) could not be opened. Windows Media Player version 10 or later is required." I don't know what it means I'm pretty noob when it comes to these things. I hope you can help. I am currently using windows 11, I dont know what windows media player it is talking about...
Hello Tim, thank you for the amazing videos! I have a problem with the ScrollViewer. My code is exactly like yours, but the scrollbar is greyed out. Btw I'm using Visual Studio Community 2017 Version 15.9.7 Any suggestions?
@@IAmTimCorey Thanks for the fast reply! Yes, I'm able to see just two of the images, but the other elements have been pushed to the bottom of the window. 😕
You should explain in this course why it is a bad idea to have it all in the same class, and mention your MVVM videos. I got really confused because i started making multiple classes, for the list and for the person. My mistake jumping ahead
Where is the previous lesson that you refer to in this video? I started with Intro to WPF and this was suggested as the next lesson and those steps were not in the Intro I completed watching. Thanks.
Thank you Tim, great as usual. Small question: is it possible in the ComboBox.ItemTemplate -> DataTemplate -> Image to bind the Source property to the Method : IsTim() and to pass the Parameter FirstName, so that the picture in the ComboBoxItems is shown only when the FirstName is "Tim"?
@21:59 - that doesn't work for me - a ScrollViewer with nested StackPanel, which in turn has the 4 images. I get scrollbars - but they are disabled. Setting MaxHeight="250" on ScrollViewer fixes it though. Also if you take the Orientation off the WrapPanel if it's nested it will work as expected - again with the MaxHeight set on the ScrollViewer.
You need to get the selected item. In Caliburn Micro, this is fairly easy. You just specify the property that will store the SelectedItem and you are done. Now you can access that object in the ViewModel whenever you want.
ok. so I tried out wpf. One thing I tried was to trigger an event that calls a method, that returns a string. Returned string is ment be a image source path. Turns out you can't do it. Method (string) { ImageName.Source ="string". } cannot implicitly convert string to source. Interesting. What do you do with that?
I thought I did that in the previous WPF video but maybe not. Basically, put the control in an expanding column (one with a star for the size, not auto) then make sure the control does not have a width property (the same can be true for the row and height property if you want it to get taller too). Now when your form expands, so does your control.
So im trying to display a list with data binding, but the problem I have is that newly added items get added to the ui but if i change the name of an already displayed item it doesn't refresh. Is this intendet behaviour and i have to do something to refresh it or is this bug of some kind i have here.
Great tutorial! Any thoughts as to why resizing my form (after adding the image control) also resized my text box and combobox? I notice the same doesn't occur in your demo app, and I think we have the same markup code.
Look at your column definitions. If you don't have the star column, each column will resize to fill the space. The other option is that you have your controls in a star column.
sizing doesn’t work, image or media likewise. I tried adding specifiers like “fill” etc, reopening the studio, nope. Not just media window, but controls too. I can specify the size, but this isn’t cool. I am running VS on windows 7, I can see at the header the “markup-compatibility/2006, ..winfx/2006/xaml etc. Could that be the problem or should I look furher?
@@IAmTimCorey , i didn't set "copy to output" thats why. Thanks @The Jewel of the Nile for the fix in comments and Thanks @IAmTimCorey , for reply.
Hi Tim, first, thank you for your videos. I noticed that the images don't render smoothly as they are resized in your demo (they appear jagged.) Is this just the way it is with WPF, or is there some way to correct that?
@@IAmTimCorey ah, thank you! By the way, after watching your video on MVVM with Caliburn Micro, I visited the project's website where I saw a recent announcement that it is no longer going to be maintained. It makes me not want to invest in using it. Perhaps an idea for a newer video on this topic covering an alternative to CM.
Hi!, I'm new with wpf, but I've a lot of expierence with WF, and by the way, awesome vids!. My question is, in 8:39 in the DataTemplate, you wrote But what happen if you have a colletion of any other object, and the Property name is not found. And, Is there a way to Write an Attribute in the property to "Select" that property to be shown in the combobox?. Thank you :D
If the property is not found, you would throw an exception. Not sure what you mean about selecting an attribute. You can show specific properties in a combobox (I have a video on that), if that is what you mean.
@@IAmTimCorey mm let me explain it: [PropertyToDisplayAttributte] public string PropertyName { get{ return "Hello";} } in that way, it doesn't matter the property name, you could just search the attributte ( I don't know if that's possible), and I'm asking that because. What happen if I try write a style template?, for example, for a combobox I need specify the DataTemplate in order to code how it suposse to show each Item, but if in other moment I want use exactly the same style but instead to show Persons, I want to show cars, how is this possible?, using an Interface? Thank you for your quick answer :D
Great content as always. Thank you so much. I ran into a small problem with not having permission to load an image from my pictures folder into the app, but once I created a C:\temp folder and moved the image to it, it loaded fine. Is WPF similar to WinRT in that I have to add a capability to a manifest file? I looked for a similar file, but I could not find it. I did look in App.config. I also thought I may have to add that image to the resources, but they don't look like folder that you can add files to.
Nope, it isn't like WinRT. You have the full capabilities of whatever user is running it (although you need to elevate it if you want access to admin-level items).
Trying the code in WPF for dotnet Core. I see that the main C# code looks quite different. Could you give a code example for the c# code (I am at about 3:30 in the video). TIA. BTW very nice videos!
moving from flutter to c# let me tell you that flutter is so much better and easier and beautiful interface than c#/xaml but companies and startups doesn't want dart/flutter devs so they force engineers and programmers learn c# .net... I wish xaml was just like flutter... edit: and btw its kinda confusing because rows in flutter are horizontal and columns vertically 😁
I can see how learning a new language can be difficult. Part of the issue is how new Flutter is relative to C#. As for the rows and columns, they are the same as Flutter. Rows in WPF are horizontal and columns are vertical.
I don't have a video that covers that but this StackOverflow topic might help: stackoverflow.com/questions/5409259/binding-itemssource-of-a-comboboxcolumn-in-wpf-datagrid
At around 4 mins. 15 seconds you add the code myComboBox.ItemsSource = people; to the MainWindow() My question: Is that just a preference or is it because it's a List? I was following along with an ObservableCollection and in the XAML seems to work. Is this a valid way to do it as well?
Good question. First of all, I tend to do bindings like this in code because I can control the timing of when it gets added better. Second, I try not to put bindings directly in the XAML. It is just one more place I have to remember to update when I change the list or otherwise modify the binding. Third, having all of the data manipulation in the code behind (or, better yet, in a ViewModel) allows me to more easily see what is happening by looking in just one spot. With that said, there is nothing wrong with the way you are doing it. It is definitely a valid solution.
Here is the link to the full course with the two add-on courses (WPF and MVC): iamtimcorey.com/p/c-application-from-start-to-finish-complete-bundle Here is a link to just the full course: iamtimcorey.com/p/c-application-from-start-to-finish
If you used relative paths, make sure they are being copied over to the output folder. Otherwise they won't be in the same location relative to your application.
@@IAmTimCorey I mean the button on the combo box. It is on the side of the combo box not on top. Do I need to do something the orientation of combo box? Thanks. I hope you could understand me now.
I had the same problem. It turned out to be that Row 4 was set to "*"- so it made the row tall (using the remaining vertical space until reaching the "20" pixel row set for the bottom border). In my project, I an added an additional row (to the RowDefinitions), so row 4 now was "auto", and row 5 was "*".
Technicality: Throughout the video, it sounds like you are saying "APF" not "WPF". The sound "Double You' is hard to miss, and it sure sounds like "a' :(
The dollar sign is used in string interpolation. That is where you insert C# code into a string like "Hello { FirstName }" where FirstName is a variable. The result would be "Hello Tim" when it runs (if Tim was the value of FirstName).
@@IAmTimCorey Thank you for your response. I thought that the brackets would he enough for the interpolation, but they have to be coupled with the dollar sign before the actual string begins.
thanks for the combox I put :" " instead of if not , I receive this msg :" Items collection must be empty before using ItemsSource." what do you think ? thanks to you
I'm pretty sure this is a problem on your end (Internet filter, connectivity glitch, etc.) since it is viewable on my devices and 979 people have watched it for over 7,000 minutes this month. Try loading it again and seeing what happens. If it doesn't work, I'd say you need to start looking at your PC or network.
They must have named it MediaElement, because you can run movies, music, probably powerpoint and more. If you want video, you have to name the others as well, and that would be a loss in functionality if you ask me.
Is this a “tease” for your paid lessons? I’d like to see more advanced WPF tutorials for free from you. WPF has been our for many many years. Why an introduction just now? Aren’t these “a dime a dozen” on RUclips?
No, I don't do videos just as a tease for my paid lessons. My paid lessons help fund my free content. I don't hold back in my free content. As for why do a video on WPF controls now, the answer is because it was a popular request. I maintain a suggestion list based upon what people ask for via comments and emails. I then prioritize what I am going to teach partially based upon that suggestion list. As for wanting more advanced WPF videos, have you checked out the WPF playlist I have: ruclips.net/p/PLLWMQd6PeGY3QEHCmCWaUKNhmFFdIDxE8 It has more content on WPF and MVVM that might be of help. I also use WPF as my desktop application in the TimCo Retail Manager series here on RUclips: ruclips.net/p/PLLWMQd6PeGY0bEMxObA6dtYXuJOGfxSPx If you are looking for something more specific, let me know and I'll add it to the suggestion list (or upgrade the priority of it a bit if it is already there).
lol, you liked that when I expanded it to full screen? When I was doing my testing, I accidentally expanded it to the full height of my desktop. Since I have four monitors in a 2x2 configuration, that meant that my image got HUGE! That was a bit unnerving.
This is TERRIBLE. You do NOT introduce something as BASIC as 'adding items to a drop down list' by introducing a class object collection and a Data Template. You do the '1 step at a time', not 'you need to add 3 things to do this, when a simple example could use 1" Very bad form. If you want to add "Master, Visa, Discover, Amex", you should be able to do this simple example, but this video does not show that basic, simple example.
Well, there are a couple things at play here. First, this isn't the intro video I did previously. Second, this particular case was one that was HIGHLY requested by my audience. Third, this is much more common a scenario than the one you propose. Let's say you have those four items. How do you represent them when capturing the form? As text? That's all you can do since you can't include a key as well without having some type of object. So now you are storing "Discover" in the database every time you say that a person has a Discover card? That's awful for storage space, for lookup speed, and for extensibility. So, if you want to use a dropdown in the real world and not just in a silly demo, you almost always want it to be connected to an object or data set of some type. That's what I demoed so you know how to do it. I don't write code so it works in a test environment. I show you how to write code that you can actually use in the real world.
Fair enough, partly. But to the extent that what you just told me is not something that anyone else would know coming in, I think it would be HUGELY BENEFICIAL, if you had a little 'context' up front, telling people something like "I assume that you have already seen the previous, prerequisite video xxx". Then people like me don't make an ass of themselves mistakenly thinking "Ok, this is WPF 101.." Your second point is totally valid, but also addressed by telling people like me (per previous sentence) "As a follow up request...", which again saves me from looking like an ass. And as to your 3rd point: Ok, but again, a Newbie would not know that (unless they make an ass of themselves as I have done here), so SAYING "You might think you would populate this with a simple array but we don't because..." is an extra 30 seconds but - in my defense - this is the kind of honest WHY NOT??? mistakes that people like me make. Thank you VERY MUCH for what you said, I just ask that you bear in mind that to the VERY NEWBIEs who cling to your every word, a little 'ramp up intro/context' would be VERY helpful!! THANK YOU. I apologize for my outburst. I am having a devil of a time wrapping my head around this, and just wish there were a handbook or something that broke this down into basic pieces, and then explained them in context. Your videos are GREAT, can't believe they are FREE., and again, please accept my apologies. Henry
@@henrygene5899 He did say that in the video. In the beginning he explicitly states this isn't the first video in the series and this is continuing off his "Intro to WPF" video.
Even 3 years later these are the best you can find
Thanks!
I spent a ton of time trying to figure out the ins and outs with the newer Win UI3. There was no beginner-friendly resources, especially ones that focussed more on the 'how' and 'why' instead of 'what' when it comes to XAML. I'm so glad I took a step back to WPF, as your tutorials are very comprehensive and put many of the principles into perspective. A few years late, but I just wanted to say thank you so much!
I am glad it was helpful.
0:00 - Intro
0:29 - ComboBox
2:53 - ComBobox Data: Creating a List of T
4:06 - ComBobox Data: Assign a List of T to the ComboBox and display property of T
9:37 - Image
12:18 - MediaElement
14:22 - StackPanel
18:22 - WrapPanel
20:44 - ScrollViewer
23:05 - StackPanel inside ComboBox
26:18 - Item Parent and placement
28:20 - Summary and concluding remarks
Thank you!
As an old dinosaur doing winforms for almost 20 years, thank you it is a good introduction to WPF. Will switch to WPF soon
Awesome!
Hi Tim, just getting back into WPF from a 10 year break, your intro videos are just the job. Thank you. Cheers Dave
I am glad they were so helpful.
Very practical and you pick up so many gotchas that many beginners would otherwise be wondering about. Thanks for the amazing content Tim.
You are most welcome. Thanks for watching.
Thank´s a lot... I'm trying to move from VBA to VSTO and XAML... You are making this task easy!!
Hugs from Brazil!!
Excellent! I'm glad these videos are a help.
played with WrapPanel Inside the ScrollViewer, when you disable the default VerticalscrollBarVisibility="Visible" to Disable, the WrapPanel with Orientation="Vertical" works just fine again :) if you think about it, as long as you can scroll, the WrapPanel dont need to Wrap, first when the Scrolling in Vertical-Side is disabled, it's need to wrap and does so
Thanks for sharing.
You are brilliant tutor. This is my first video of WPF, infact new to C# but your tutorial is really helpful for a beginner like me to start with.
I'm glad this video was helpful.
Awesome news about the WPF-port for "From Start To Finish" - can't wait for that one . . .
Good work so far!
Yep, that one got an overwhelming response. Still trying to figure out how I'm going to do it but it will definitely happen.
your teaching method is excellent. just waiting your WPF update to your original course....thanks for passing the knowledge
I appreciate it.
If somebody has a problem with playing video ( 13:15 ) there is a solution:
1. Right click your video file in the solution explorer and chose "properties".
2. Make sure Build Action is set to "Content".
3. Make sure Copy to output is set to "Copy Always" or "Copy if Newer".
Thanks for the tip!
Thanks for this tutorial! :)
@@IAmTimCorey 夷卍了”。金一杠力s
Mdddjjddi
Wow!!! Just so in love with WPF now... Thank you Tim!!!
Awesome!
You are a great teacher i wish we had teachers like you in my college, As Indian's we proud of our IT sector but our institute's lake good teachers, love from India
I appreciate the kind words.
Hello mr. Corey, I might be late to the party few years. Just realised the MediaElement is media and video probably because since I didnt have video, I was able to add MP4, which doesnt contain any image, just sound. Might be because you can add more elements than just video. And by the way, thanks for this tutorial ! The way you explain things is awesome :)
Great!
I just clicked the Like button , but where is the love button :D!! very good video. I'm working with WPF and MVVM pattern also for a work project, but with this videos I'm filling up my gaps, I really trust that the tutorial will be more complex (the future tutorials) so thanks for your time. !
I am glad you enjoyed the content.
Notes to myself;
6:20 : To connect a combobox to a propertie Firstname o/t class "Person"; add
20:36 : Scrollviewer
Thanks for the tip
@@tomthelestaff-iamtimcorey7597 ... i'm just making notes for myself ;-)
I like the Scroll viewer. thanks for showing these controls! :)
You are welcome.
Really awesome features, good video! Looking forward seeing datagridview-ish controls.. I am hyped seeing only the controls in this videos.
Glad you liked it.
Tim, Would you consider doing another WPF video. Couple of thing I am interested in is:
1. Animations.
2. Data Grids
3. Custom Contols
I will definitely be doing another WPF video and these are good topics to be sure are on the list. Thanks for the suggestions.
MediaElement supports also .mp3 files, so maybe that's why it is not called only VideoElement.
Thank you for the tutorial!
Good thought.
best tutorials still i have found related WPF !
I'm glad you like them.
This is some amazing teaching skill here.
Thanks again!
I spent my sweet time messing around with the stackpanel and image elements before finally moving on XD
That's ok. Learning by trying things out is an excellent teacher.
Thank you very much. This is very informative
You are very welcome.
Man WRAPPANEL and other controls in WPF we take it for granted, just imagine implementing that in C++ all those manual resizing and re renderings. All of that math you have to perform manually, I'm glad I am a C# programmer.
Yep, there are LOTS of benefits.
Excellent teaching
Thank you.
Suggestion: Admittedly, this is 'young grasshopper' opining to 'Master Yoda' (and mixing about 3 generations of metaphors along the way...), but may I suggest that to give students a fuller understanding of ComboBoxes, that you start by saying something like "There are 2 ways to populate a ComboBox: Statically and dynamically. Statically is just like adding a Master Card , etc for each option. Pretty simple. Now the really interesting and more typical is a dynamic, data-driven one like this PEOPLE example I'm going to show you...". One on-going disappointment I have with a LOT of training courses is that they often show only one way (like the above), but do not even allude to any other options, misleading the student to think that there is no other way than the example shown. Thanks for listening :)
I hear you and I try to do that when I think it is important. However, in this case I'm not really a fan of encouraging people to add things to a combo box statically. You could argue that some things never change but I've been around long enough to know that isn't really true. Even if you had days of the week in the box, at some point someone is going to want to change those to abbreviations or they are going to want to localize them. Either way, you now have to open your application and recompile it.
Great learning .
Thanks!
6:30 three days i ve been stuck on this , tried all sorts of shit to display the fkin names on list box , then i figured it out by using linq i sorted lists.Name option, then when i tried to deleted the particular item i coudnt able to get the id of that particular item,. Engneering is a hard if not guided in a right way , thanks for his sir...i will watch all of your videos and siply write a comment , thats all i can do atm
I am glad you got it figured out.
Very helpful. Thanks
You are welcome.
Thanks a lot for this. This cleared my doubts
Awesome.
Thank you for sharing these great tuts
You are welcome.
Awesome tutorial
Please upload more videos of WPF !!!!!!!!!
please
Your are great
Thanks! And yes, more WPF videos are coming.
This is a great continuation of the intro video to WPF. I wonder if there is a sequel to "this" video?
There is a whole playlist for WPF here: ruclips.net/p/PLLWMQd6PeGY3QEHCmCWaUKNhmFFdIDxE8 plus I use WPF in the TimCo Retail Manager series.
I would be curious to see how to create custom WPF controls from simple to complex.
I cannot seem to find anyone with a video on how to instantiate a controltemplate or usercontrol in code behind. This is totally needed for cases when data is driving how many controls you need at run time, for example an image grid where you load according to how many pics returned by a sql statement, etc.
I can add that to the suggestion list.
Brilliant!
Thanks
Hi Tim, great tutorial as always.
I started to make simple classic games in C# like snake, tetris, pong etc.I have already made Snake in Windows Forms.
Now I want to try WPF, so I have few questions.
1.In WF I used the pictureBox control and the Graphics class to draw shapes. What should I use in WPF ?
2. How to correctly center a form on different screen resolutions? When I use the property WindowStartupLocation = "CenterScreen", it works only for resolutions greater than specified form size, otherwise it's cut vertically.
Classic games in WPF are much more possible in WPF. Unlike WinForms, where you were pushing the edge to get anything to work, WPF is designed for movement and drawing. In fact, all of the controls have the ability to animate and change built-in. I'd start by checking out this article: docs.microsoft.com/en-us/dotnet/framework/wpf/graphics-multimedia/animation-overview
Then I'd look at this article: www.c-sharpcorner.com/UploadFile/52f7b2/wormrace-using-wpf-animations/
Those two should get you started not just in drawing the shapes but in animating the movement.
As for question two, I think you are mostly at your solution. I would just do a check on startup to see what the screen resolution is, and if it is smaller than the form, just maximize the form. Then it will take the available space, and even though it isn't as much as you want, at least you won't have any off-screen issues. Then you just need to make sure your form can run at the smaller size without an issue.
Thanks for the tips.
PS: If someone had a problem with moving shapes using the Canvas.SetTop (Left, Right ...) method and the timer tick event.
You must first initialize the Top value for shape in C# or XAML
XAML:
Canvas.Top = "0"
C#:
Canvas.SetTop (shape, 0);
Then you can use this in your timer tick
Canvas.SetTop (shape, Canvas.GetTop (shape) + value);
It took me a few hours to get it working .... I should use WPF animation :))
Hey, you make amazing videos! I wanted to know if you could recommend what I should do about this. I'm wanting to make an IPTV m3u channel list application, which lists channels with a timeline of the shows that premiere at a certain time. Normally there are about 1500+ channels and even more shows. Do you know any good way to show this data without crashing and lagging the whole window? I tried this in WinForms and it is just a complete lag disaster. I wanted to make a list menu on the left side, and when you go to click the item it brings up the channel information on the right. Thank you Tim! Or if you have another suggestion of how I should show this data?
Thanks!
Thank you!
This is so helpful! Is there any chance you can talk about embedding a web browser element and working with the DOM (doing all of CRUD) in a WPF app?
Have you looked thru Tim's fill WPF playlist? ruclips.net/p/PLLWMQd6PeGY3QEHCmCWaUKNhmFFdIDxE8
@@tomthelestaff-iamtimcorey7597 I haven't yet watched them all, but on scrubbing through them I see no use of an embedded web browser tool. Am I missing something?
Hi Tim, Great videos I must say! is it possible to make a video where you, take the user input from the textboxes and saves them in a .txt file? I'm trying to make a simple string creator tool in WPF. And alså with the combo boxes. How is it possible to, show the same as you are doing in the video, but where it reads from a .txt file instead. Hope you understand what I mean. I'm pretty new to programming. I'm looking at your videos to learn, you are a great teacher! :D
sorry for this late question, but maybe i am lucky :) . the DataTemplate, its it possible in VS to save it as a "external file" and just refer to it instead. So i can have seperate files whit difrent templates so its easyer to work whit and se whats happening :) sorry about the bad Eng not my first lang. Thx
If I understand your question then the answer is no, you cannot.
IAmTimCorey okay thanks :)
Fire emojis Tim!!
Thanks!
Can u say to me, what source is the best to use to learn wpf and c# programing? By the way,ur tutorials is the best
My Foundation in C# course series is the best place to start. It will give you a firm understanding of all of C# and it will also cover the start of WPF. That way you are ready to progress to more in-depth learning on WPF. Here is a video that shows you more about how to get started: ruclips.net/video/LUv20QxXjfw/видео.html
Hello Tim, I'd like to bind Radiobuttons to a boolean but I read this: The radio button control has a known issue with data binding. If you bind the IsChecked property to a boolean and check the RadioButton, the value gets True. But when you check another RadioButton, the databound value still remains true.
Would you say that is still the case and one needs to make a workaround for it?
If you are doing manual binding, here is a solution: www.wpftutorial.net/RadioButton.html If you are using Caliburn Micro, it is even easier: stackoverflow.com/questions/14341484/set-radiobutton-checked-in-code-with-caliburn-micro
hey corey, I hope youll reply. So I was following your steps and then I had a problem in the mediaelement part. It doesnt show in the editor view as well as in runtime. I tried dragging it into the form but an error message popped up "The media file (filepath) could not be opened. Windows Media Player version 10 or later is required." I don't know what it means I'm pretty noob when it comes to these things. I hope you can help. I am currently using windows 11, I dont know what windows media player it is talking about...
Hello Tim, thank you for the amazing videos!
I have a problem with the ScrollViewer. My code is exactly like yours, but the scrollbar is greyed out.
Btw I'm using Visual Studio Community 2017 Version 15.9.7
Any suggestions?
Is it actually big enough to scroll?
@@IAmTimCorey Thanks for the fast reply! Yes, I'm able to see just two of the images, but the other elements have been pushed to the bottom of the window. 😕
You should explain in this course why it is a bad idea to have it all in the same class, and mention your MVVM videos.
I got really confused because i started making multiple classes, for the list and for the person.
My mistake jumping ahead
¨Btw. This is way more informative and goalongtoo than the way my teacher does. Amazing
I do explain that in some videos but I don't in all of them. One class per file. That's the best practice.
Where is the previous lesson that you refer to in this video? I started with Intro to WPF and this was suggested as the next lesson and those steps were not in the Intro I completed watching. Thanks.
Here you go: ruclips.net/video/laPFq3Fhs8k/видео.html
@@IAmTimCorey Thank you!!
Thank you Tim, great as usual. Small question: is it possible in the ComboBox.ItemTemplate -> DataTemplate -> Image to bind the Source property to the Method : IsTim() and to pass the Parameter FirstName, so that the picture in the ComboBoxItems is shown only when the FirstName is "Tim"?
Yes, it is possible to do that. I don't have an example to show you though.
@21:59 - that doesn't work for me - a ScrollViewer with nested StackPanel, which in turn has the 4 images. I get scrollbars - but they are disabled. Setting MaxHeight="250" on ScrollViewer fixes it though. Also if you take the Orientation off the WrapPanel if it's nested it will work as expected - again with the MaxHeight set on the ScrollViewer.
Interesting.
thanks for the fix
Hi, how do I get the information from combobox to display in messagebox? how can I get the text show or get the reference to object person?
You need to get the selected item. In Caliburn Micro, this is fairly easy. You just specify the property that will store the SelectedItem and you are done. Now you can access that object in the ViewModel whenever you want.
@@IAmTimCorey thanks, after some time I figure out the use the operator "as" :(combo.selectedItem as Person).FirstName
ok. so I tried out wpf. One thing I tried was to trigger an event that calls a method, that returns a string. Returned string is ment be a image source path. Turns out you can't do it.
Method (string)
{
ImageName.Source ="string".
}
cannot implicitly convert string to source. Interesting. What do you do with that?
This seems to work.
internal static ImageSource GetImage(string imagename)
{
string path = @$" ...Your path... \Images\{imagename}.bmp";
ImageSource output = new BitmapImage(new Uri(path));
return output;
}
}
I am glad you got it to work.
Great thank you
You are welcome.
Hi Tim, you didn't show how to expand the controls when resizing the window. thanks
I thought I did that in the previous WPF video but maybe not. Basically, put the control in an expanding column (one with a star for the size, not auto) then make sure the control does not have a width property (the same can be true for the row and height property if you want it to get taller too). Now when your form expands, so does your control.
Thank you
So im trying to display a list with data binding, but the problem I have is that newly added items get added to the ui but if i change the name of an already displayed item it doesn't refresh. Is this intendet behaviour and i have to do something to refresh it or is this bug of some kind i have here.
Great tutorial! Any thoughts as to why resizing my form (after adding the image control) also resized my text box and combobox? I notice the same doesn't occur in your demo app, and I think we have the same markup code.
Look at your column definitions. If you don't have the star column, each column will resize to fill the space. The other option is that you have your controls in a star column.
sizing doesn’t work, image or media likewise. I tried adding specifiers like “fill” etc, reopening the studio, nope. Not just media window, but controls too. I can specify the size, but this isn’t cool. I am running VS on windows 7, I can see at the header the “markup-compatibility/2006, ..winfx/2006/xaml etc. Could that be the problem or should I look furher?
fixed
MediaElement not showing in the output window but showing in Editor window, why?
I'm in vs2019
In the Output window? Do you mean the application when it is running? If so, the path to your file is probably incorrect.
@@IAmTimCorey , i didn't set "copy to output" thats why.
Thanks @The Jewel of the Nile for the fix in comments and Thanks @IAmTimCorey , for reply.
Hi Tim, first, thank you for your videos. I noticed that the images don't render smoothly as they are resized in your demo (they appear jagged.) Is this just the way it is with WPF, or is there some way to correct that?
I believe that had to do with the image I was using and the pixel density of it. I don't think that was a WPF issue.
@@IAmTimCorey ah, thank you! By the way, after watching your video on MVVM with Caliburn Micro, I visited the project's website where I saw a recent announcement that it is no longer going to be maintained. It makes me not want to invest in using it. Perhaps an idea for a newer video on this topic covering an alternative to CM.
Nice 👍
Thanks!
Hi!, I'm new with wpf, but I've a lot of expierence with WF, and by the way, awesome vids!.
My question is, in 8:39 in the DataTemplate, you wrote
But what happen if you have a colletion of any other object, and the Property name is not found.
And, Is there a way to Write an Attribute in the property to "Select" that property to be shown in the combobox?.
Thank you :D
If the property is not found, you would throw an exception. Not sure what you mean about selecting an attribute. You can show specific properties in a combobox (I have a video on that), if that is what you mean.
@@IAmTimCorey mm let me explain it:
[PropertyToDisplayAttributte]
public string PropertyName { get{ return "Hello";} }
in that way, it doesn't matter the property name, you could just search the attributte ( I don't know if that's possible), and I'm asking that because. What happen if I try write a style template?, for example, for a combobox I need specify the DataTemplate in order to code how it suposse to show each Item, but if in other moment I want use exactly the same style but instead to show Persons, I want to show cars, how is this possible?, using an Interface? Thank you for your quick answer :D
Great content as always. Thank you so much. I ran into a small problem with not having permission to load an image from my pictures folder into the app, but once I created a C:\temp folder and moved the image to it, it loaded fine. Is WPF similar to WinRT in that I have to add a capability to a manifest file? I looked for a similar file, but I could not find it. I did look in App.config. I also thought I may have to add that image to the resources, but they don't look like folder that you can add files to.
Nope, it isn't like WinRT. You have the full capabilities of whatever user is running it (although you need to elevate it if you want access to admin-level items).
Why does one put design items like stackpanel inside the DataTemplate? Breaks with single responsibility?
No, single responsibility doesn't really apply here. This is about creating the correct layout for our data.
Trying the code in WPF for dotnet Core. I see that the main C# code looks quite different. Could you give a code example for the c# code (I am at about 3:30 in the video). TIA. BTW very nice videos!
If you look at the TimCo Retail Manager series when we upgrade to .NET Core, you will see how to set up a .NET Core WPF app.
moving from flutter to c# let me tell you that flutter is so much better and easier and beautiful interface than c#/xaml but companies and startups doesn't want dart/flutter devs so they force engineers and programmers learn c# .net... I wish xaml was just like flutter...
edit: and btw its kinda confusing because rows in flutter are horizontal and columns vertically 😁
I can see how learning a new language can be difficult. Part of the issue is how new Flutter is relative to C#. As for the rows and columns, they are the same as Flutter. Rows in WPF are horizontal and columns are vertical.
@@IAmTimCorey awesome, thanks man I appreciate you answer u should try implement material design to the WPF it's really cool and customizing 👍
Datagrid Bindings are something I am struggling with. Especially ComboBoxes in a datagrid.
I don't have a video that covers that but this StackOverflow topic might help: stackoverflow.com/questions/5409259/binding-itemssource-of-a-comboboxcolumn-in-wpf-datagrid
At around 4 mins. 15 seconds you add the code myComboBox.ItemsSource = people; to the MainWindow()
My question: Is that just a preference or is it because it's a List? I was following along with an ObservableCollection and in the XAML seems to work. Is this a valid way to do it as well?
Good question. First of all, I tend to do bindings like this in code because I can control the timing of when it gets added better. Second, I try not to put bindings directly in the XAML. It is just one more place I have to remember to update when I change the list or otherwise modify the binding. Third, having all of the data manipulation in the code behind (or, better yet, in a ViewModel) allows me to more easily see what is happening by looking in just one spot. With that said, there is nothing wrong with the way you are doing it. It is definitely a valid solution.
Do you have the full course link?
Here is the link to the full course with the two add-on courses (WPF and MVC): iamtimcorey.com/p/c-application-from-start-to-finish-complete-bundle
Here is a link to just the full course: iamtimcorey.com/p/c-application-from-start-to-finish
My Image and Media Elements don't show up when I hit Start and the app runs. They show up in designer but not at run time. Any explanation for this???
If you used relative paths, make sure they are being copied over to the output folder. Otherwise they won't be in the same location relative to your application.
@@IAmTimCorey Ive actually just solved the issue and learned quite a bit in the process. Thanks for the prompt reply!
Hi, Thanks a lot. Why does my combox has it is main button on the side and not on top?
I'm not following what you mean. My button was below my combo box and that was because I put it in the next grid row down.
@@IAmTimCorey I mean the button on the combo box. It is on the side of the combo box not on top. Do I need to do something the orientation of combo box? Thanks. I hope you could understand me now.
I had the same problem. It turned out to be that Row 4 was set to "*"- so it made the row tall (using the remaining vertical space until reaching the "20" pixel row set for the bottom border). In my project, I an added an additional row (to the RowDefinitions), so row 4 now was "auto", and row 5 was "*".
Hi Tim, was following this tutorial and got an error when trying to use binding at 7:30 without having a set part of the FullName variable.
Interesting. Not sure why. You can definitely have a get with no set. If it forced you to, create a set but don't put any code in it.
@@IAmTimCorey Thanks for the reply, essentially what I ended up doing. Thank you for the amazing tutorials!
Technicality: Throughout the video, it sounds like you are saying "APF" not "WPF". The sound "Double You' is hard to miss, and it sure sounds like "a' :(
Bummer.
Hi , Please tell me how to set and get value from datagrid cell in wpf.
Please help me I really need it.
I'll be covering this in a future video.
Please make video early
What means the dollar sign in the return statement?
The dollar sign is used in string interpolation. That is where you insert C# code into a string like "Hello { FirstName }" where FirstName is a variable. The result would be "Hello Tim" when it runs (if Tim was the value of FirstName).
@@IAmTimCorey Thank you for your response. I thought that the brackets would he enough for the interpolation, but they have to be coupled with the dollar sign before the actual string begins.
thanks
for the combox I put :" " instead of
if not , I receive this msg :" Items collection must be empty before using ItemsSource."
what do you think ?
thanks to you
In the video I used ComboBox.ItemTemplate (like at 9:00). Did you flip those around or are you referring to somewhere else?
sorry I sorry sorry i didnt saw it thanks for your reply
No problem. Glad you got it figured out.
Having an issue unable to view the video on runtime
I'm pretty sure this is a problem on your end (Internet filter, connectivity glitch, etc.) since it is viewable on my devices and 979 people have watched it for over 7,000 minutes this month. Try loading it again and seeing what happens. If it doesn't work, I'd say you need to start looking at your PC or network.
They must have named it MediaElement, because you can run movies, music, probably powerpoint and more. If you want video, you have to name the others as well, and that would be a loss in functionality if you ask me.
Yeah. Naming is hard.
MediaElement doesn't work.
I'm not sure how to help here. It is probably a configuration issue.
sorry but i didn't see any complexity in WPF and XAML, it just need some time for adaptation
I'm glad you don't find it complicated. Enjoy.
ruclips.net/video/-zM486rVopk/видео.html
would the WrapPanel work in the ScrollViewer as expected if its orientation was set to horizontal?
Yes, if you turn the WrapPanel's orientation to horizontal, it does work with the ScrollViewer. Thanks for pointing that out.
Is this a “tease” for your paid lessons?
I’d like to see more advanced WPF tutorials for free from you.
WPF has been our for many many years.
Why an introduction just now?
Aren’t these “a dime a dozen” on RUclips?
No, I don't do videos just as a tease for my paid lessons. My paid lessons help fund my free content. I don't hold back in my free content. As for why do a video on WPF controls now, the answer is because it was a popular request. I maintain a suggestion list based upon what people ask for via comments and emails. I then prioritize what I am going to teach partially based upon that suggestion list. As for wanting more advanced WPF videos, have you checked out the WPF playlist I have: ruclips.net/p/PLLWMQd6PeGY3QEHCmCWaUKNhmFFdIDxE8 It has more content on WPF and MVVM that might be of help. I also use WPF as my desktop application in the TimCo Retail Manager series here on RUclips: ruclips.net/p/PLLWMQd6PeGY0bEMxObA6dtYXuJOGfxSPx
If you are looking for something more specific, let me know and I'll add it to the suggestion list (or upgrade the priority of it a bit if it is already there).
Your avatar is getting creepy tim.
lol, you liked that when I expanded it to full screen? When I was doing my testing, I accidentally expanded it to the full height of my desktop. Since I have four monitors in a 2x2 configuration, that meant that my image got HUGE! That was a bit unnerving.
6:30
This is TERRIBLE. You do NOT introduce something as BASIC as 'adding items to a drop down list' by introducing a class object collection and a Data Template. You do the '1 step at a time', not 'you need to add 3 things to do this, when a simple example could use 1" Very bad form. If you want to add "Master, Visa, Discover, Amex", you should be able to do this simple example, but this video does not show that basic, simple example.
Well, there are a couple things at play here. First, this isn't the intro video I did previously. Second, this particular case was one that was HIGHLY requested by my audience. Third, this is much more common a scenario than the one you propose. Let's say you have those four items. How do you represent them when capturing the form? As text? That's all you can do since you can't include a key as well without having some type of object. So now you are storing "Discover" in the database every time you say that a person has a Discover card? That's awful for storage space, for lookup speed, and for extensibility. So, if you want to use a dropdown in the real world and not just in a silly demo, you almost always want it to be connected to an object or data set of some type. That's what I demoed so you know how to do it. I don't write code so it works in a test environment. I show you how to write code that you can actually use in the real world.
Fair enough, partly. But to the extent that what you just told me is not something that anyone else would know coming in, I think it would be HUGELY BENEFICIAL, if you had a little 'context' up front, telling people something like "I assume that you have already seen the previous, prerequisite video xxx". Then people like me don't make an ass of themselves mistakenly thinking "Ok, this is WPF 101.." Your second point is totally valid, but also addressed by telling people like me (per previous sentence) "As a follow up request...", which again saves me from looking like an ass. And as to your 3rd point: Ok, but again, a Newbie would not know that (unless they make an ass of themselves as I have done here), so SAYING "You might think you would populate this with a simple array but we don't because..." is an extra 30 seconds but - in my defense - this is the kind of honest WHY NOT??? mistakes that people like me make.
Thank you VERY MUCH for what you said, I just ask that you bear in mind that to the VERY NEWBIEs who cling to your every word, a little 'ramp up intro/context' would be VERY helpful!!
THANK YOU.
I apologize for my outburst. I am having a devil of a time wrapping my head around this, and just wish there were a handbook or something that broke this down into basic pieces, and then explained them in context.
Your videos are GREAT, can't believe they are FREE., and again, please accept my apologies.
Henry
@@henrygene5899 He did say that in the video. In the beginning he explicitly states this isn't the first video in the series and this is continuing off his "Intro to WPF" video.
9:30