Mention: VS2019 doesn't set the build action for images by default, so if you want to use images with image sources just like "Images/[...]" or "/Images/[...]", you have to set the build action from "none" to "resource" for this image, otherwise it won't be rendered (just click on the image and press f4 to open this property menu. select the dropdown "build action", that's it). Found it out after watching and building your UI. Great tutorial, thank you very much!
Thanks for this, I was trying to set the folder to resource and it was doing my head in....at least this is a work around. Also remember, if you do not run a code clean-up after doing this...it will report the same error.
@@TheDuerden Thank you so much! This fixed it for me. FYI for anyone else: To run Code Cleanup, go to one of your .cs scripts and click the little broom icon in the bottom left.
I know I’m late to the party but man I hope you haven’t stopped teaching cause I’m telling you’re gifted for this. I’m just getting into WPF sure feel little overwhelmed but the content is pure Gold thanks for the effort spent to creating this content.
When I encountered your tutorial I thought who will watch for one hour, but when I started watching believe me I am immersed in it. The explanation is amazing. Please do continue your work like this. Those who can't afford money for tutorials for them you are creating platform with your channel to learn technologies. Thank you so much for creating these kind of videos.
Thanks. Yeah I do them for people who really want to learn the whole process of real-world code. It isn't designed as a quick tip or learn this little bit, its more of a full training course :)
This is awesome once again. I am soo excited for the future videos. Finally someone capable of explaining guiding us all the way through. Thank you man for sharing this with us ;)
Thanks. I'll try and get the next video done tonight if possible, to get into the ViewModel stuff and the DNA framework and make a real start on the chat app after that video
bnfgh123 this series is for people who know c# and programming but not WPF. So it may be hard to follow if you don't already know the main programming language and concepts already. I plan to make a true beginners WPF series shortly
Well, I'm currently learning C#, but the main problem is, that I can't really find the right order in which I should learn the different features and when I stumble upon anything about C# I just try and see, whether I can or cannot comprehend. Wish that I could find some reasonably paced, ordered and complete series about the language. But judging by the first video, this series on WPF is one of the best tutorials I found so far, I'll just have to do a little bit more training on C# itself and then come back.
AngelSix Honestly the most struggling part I have with WPF is the data binding part. I look forward to your beginner series as I hope it covers that in more detail.
Yea, After watching his first video, then coming to this I was confused as to who his audience was. At first it did seem like total noobs.. but after watching this, it's still fairly confusing, because he explains some things like who would for a noob, but then others he explains them with little context, or as he would for someone with much more experience. This video expects knowledge of C#, OOP, and MVC Design Pattern. If you don't know at least all 3 of these, you'l prob get lost watching this. At the very least, youl have trouble understanding certain things.
My drive images were not showing up also. I googled, which indicated to set the drive image file property Build Action to Resources. That worked for some people but did not work for me. I had to set the Build Action property to Content and it was also recommended to Copy to Output Directory to Copy if newer. Setting those worked for my drive image.
Brilliant videos but I have a problem with a System.IO.IO Exception, I have checked the image variable in debug and it is showing Images/folder-closed. the exception is it cannot find the folder it is looking for images/folder-closed. i have checked all the code but cannot see where it get image instead of Image need to sort before i move onto next video hope you can point me in the right direction
I can't see images, code is same, I use VS19 while using only stack is ok, insert code in treeview inside, I can't see image github.com/samopoem/wpf/tree/master
I love this video and your presentation style but for the love of god use Path.GetFilename(path) and Path.GetDirectoryName(path). THOSE are the cross platform way of getting the trailing text after the last slash or backslash.
just for anybody that needs it, i find it easier to create a binding like that if i head over to the image properties on the right side, search for Source, click on the little square, select Create Binding and go from there, no worries about curly brackets.
Extremely nicely done video. And I like that you didn’t cut out your debugging and thinking aloud because that’s what all programmers do and it’s important to keep. You and your channel are one of a kind!
Thoroughly enjoyed the learning, Took me more than 3 Hours to reach 42:53 and then you did something with either delete or cut paste .. that messed up everything. I just couldn't follow what you did between those 20 seconds. Frustrating to restart from scratch. Since you are the best, I will.
Thanks so much for this tutorial! Very informative. The only problem I had was my images not loading. I had to click their properties and set the Build Action to 'Resource' and below that chose 'Copy Always'.
I'm pretty late to the 🎉, Although the video is so explicit, I couldn't run even the first dummy execution.😢 this is because the IDE shows: The member "HeaderTemplate" is not recognized or is not accessible and it doesn't allow me to run the code, I am working with Microsoft Visual Studio 2022, please if anybody could give a glue why this is happening?
Great video! Thank you so much for teaching. It was exactly exactly what I was looking for. So clear step by step guidance bringing to tangible ( visible :) result. And thanks for GitHub source!
If you run your application and got ''WPF Application Has Stopped Working'', it's due to unhandled exceptions( the try-catch block cant handle this anymore ).Check out this solution : www.c-sharpcorner.com/blogs/how-to-handle-wpf-application-has-stopped-working
22:40 .. what happened, I dont get it.. what a strange syntax, would mind at least give us a few words about that line: var item = (TreeViewItem)sender; ? Could you please simplify it to normal syntax? Thank you for your content, it is great! Although it is too fast sometimes :)
Everytime I run the program and I put the breakpoint at "var item = (TreeViewItem)sender:", I hover over "item" and keep getting "null". As a result, it throws an exception. I have been trying for a long time to troubleshoot that issue , but to no avail. Please help!!
Like this series so far :) I found another way to create the tree-view item and it's path and header. You could change: //Create a new item for it var item = new TreeViewItem(); //Set header and path item.Header = drive; item.Tag = drive; to var item = new TreeViewItem {Header = drive, Tag = drive}; Both works for me :) Just two ways to do the same thing :)
I'm sorry, but at 16:30 i've got no images of drives, i rewatched videos and redo the code about 5 times and i've got the same, don''t you know why? Also, when i run the program at 9:40 i have images. ( sorry for my English,i know it's pretty bad)
Thank you very much for all these tutorials, they're the best and most in-depth explanations of WPF and C# I've found on youtube. Great teacher! I'm going to start thinking of code in my head in an English accent now, which is fine by me!
I think you are one of the best at explaining coding on youtube, but at minute 15:36 when you type in directory it wont highlight, and says "the name directory does not exist in the current context" I'm a beginner to C# , if you could help me out it would be greatly appreciated. I was thinking about jumping to viewmodel basics, and would just create a class that way it does "exist", would that be better or is that not fixing the problem? using classes for this seems less confusing and more compartmentalized
Put your caret (the flashing thing indicating where your cursor is that looks like this | ) over the text, and then on the keyboad press Ctrl+. to auto-suggestion any missing namespaces. I suspect you are just missing some namespace.
Really? The value it is expecting is a bitmap. The only reason you can type a string in xaml is because there is an inbuild string to resource converter that gets called, but if you use a custom provider, and return a string, it will not then go to the string to bitmap converter... at least last time I checked it did not?
Thank you for your lecture. it was really helpful for me!! And while i am following your lesson, i coudn't find images files out. where can i get the these stuff. thank you!
Spent a frustrating hour or so trying to figure out why the images were not being displayed. Finally found a note that the Properties of the embedded images after being imported have to set with the properties "Build Action" = "Content" and "Copy to Output Directories" = "Copy if Newer" but that didn't work. The only way I could get it to work was with a fully qualified path. I'm using VS19 with .Net Core 3.1. Switched to use .Net Core 5.0. No change using a relative path. ARG!! Moved the project to a different directory nearer the drive root and retried again thinking that the resolved path exceeded MS 260 char limit. Seemed to work. Then did it again and verified that the resolved path was less than 260 but it didn't work. WTF. Couldn't get pack: to work and properly resolve the execution path to the png files. Had to resort to the following. // Find out where the code base is executing in order to get to the Images subdirectory string exePath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetEntryAssembly().Location); // map the subdirectory and drive image name for conversion BitmapImage bitmapImage = new BitmapImage(new Uri($"{exePath}/Images/{image}")); I really like your tutorials and work through them following along step by step in visual studio and pausing to research when I don't quite understand or like above something didn't seem to work.
what are prerequisites for this video? Your previous video isn't enough to understand this. Knowing C# basics ofcourse and prev video. Isn't that enough? What else? to follow along this playlist
Great Tutorial :) I only have one issue. The URI path at 1:03:52 does not work for me. It feels like ive tried almost everything to fix it but i get a System.IO.IOException every time. The path displayed in the exeption is correct but it does not work.
This video is extremely good. Thanks for your effort. But, as a developer who is coming from Winform, ImageSource binding was too complicated. ValueConverter was a little bit more understandable. As a result, I liked much your presentation.
At about 48:20 you say something that made the hair on the back of my neck stand up! You started talking about value converters and bindings and said something along the lines of - "This is just the simple stuff. We'll get into the more complicated things in later videos." At this point, however, my brain's already oversaturated and I know I will not even remember how to do a fraction of what you have already shown, and this is the "simple" stuff. I think I peed myself, a little bit. Also getting relative binds and going back up the tree to get the tag you mention that this is "messy" and "ugly" and here was the scary line again, you say - "and there are so many ways to get bindings...and you just get used to it.". Well, this is the overall problem learning to work within already super complication APIs. It is true there are many ways to do the same thing. But unfortunately, that means there are also many ways to try to get bindings that end up being a mish-mash of all the possible ways to do it right, that end up being WRONG! So you end up running down dead-end rabbit holes until finally, all you want to do is go watch dogs surfing on youtube!
Sincerely I found it very confusing, most of the things you know it because probably someone showed you or you did this before many times, I don't think anybody knows those properties, classes or methods that good. I passed through the code faster, it was really hard to realize what you're doing exactly sometimes. I did understand the concept, but i think you should go a little slower and describe more one specific subject.
I can add expanded event with an implicit way using ItemTreeView.Expaned in xaml; then using eventrouting (e) but I don't understand what is routedeventargs ? is that like a traveled event through all the treeitems?
Why soo many useless comments? 'Create a list for directories' that's literally what the codes says. But next to that, great tutorial. Getting to know the binding better and better. Thanks for that!
Hey.. Thanks for these tutorials. I have a suggestion. Would it be possible to make one WPF video for a Find and Replace Dialog box (with all features like RegEx, Case Sensitive, etc). I have been recently working on software that is more like a proper python-based automated scripting tool and has been done in WPF. Honestly, I couldn't find any proper youtube videos, and also the ones which are available are outdated (my feeling). I think this would be a very good idea for an advanced-level playlist for WPF. Thanks and I really appreciate your work here.
I understand this is a tutorial and you may have made this decision for the purpose of demonstration, but would it not have been a) possible and b) easier to assign the images at the point you added the files and directories to the list since they were already divided into directories, drives, and files?
I am trying to expand the folder open. I added the collapsed event to the item and subitems of the folders, something interesting happened: When i tried to collapse the subitem, the collapse event of it triggered, but then, the parent item of it also triggered the collapse event, it's bothered me for a long time.
Great tutorials, professional work. I got a question for you, given this code, how do i add another treeview to turn this app into a simple/basic file explorer? and/or can you make a quick video on a simple file explorer tutorial please?
I will be doing the next few videos down the road on creating the chat application. That will likely have a few treeviews and you will easily be able to see how that could be changed/used in a file explorer. I may come back to this example also to make it more complete
As oppose to? That is how you define your variables. If the type can be ascertained from the right hand side of the operation, like var i = 1; where 1 is an integer, then it saves writing int for no reason. This also means if you have really long types you write (fake code but as example) var a = new Func() instead of Func a = new Func()
Does anyone have any idea why the images show up at design time, but don't show up when I run. Even with the test StackPanel at the beginning (which sits outside the TreeView), when I add the image, it shows up on the layout window, but when I run, the text shows up, but no image. Likewise, when I set the style up in the TreeView and programmatically add the logical drives (in my case, just one) I get the text ("Some folder"), but no image. This frustration aside, AngelSix, your delivery is great. I think I'm going to love this series.
Im running this project on 2017 visual studio and it throws me expeption that he cant find „images/drive.png”.” even afther copy paste code from "headertoimageconventer" . Compiler doesnt recognise $"pack://application:,,,/" this form of argument
Using property bindings in XAML (instead of programatically changing properties in C#) must be related to proper MVVM practice, is that right? Is this done only to increase usability of the business logic among different UI setups? Thanks so much for the intensive training materials, most are too slow and generic to be worth the time.
Since leaving this comment, I've rebuilt some business apps and I love using NotifyPropertyChange! Set it and forget it, I haven't touched my UI in days! Although this is a concept from the next video :)
MVVM has two benefits. Firstly it forces you to not hard tie your view logic (like a button should perform an action when clicked) to the actual UI itself. Instead the logic is in the view agnostic view model. This allows for unit testing and changing or using multiple UIs with very little change. It then also forces you to think about your UI as just that, no concern for code behind, just bind to models and react according to models. That makes any significant UI element/event expressable and testable in the view model. Finally, it allows for lack of concern about the UI thread in the view model. Just change the properties, and then when the UI thats hooked into the notify events, it handles jumping back to the UI thread in one place, instead of all over your view model code.
this session is very missey when it comes to the tree view i mean the complexthing is about the directories and stuff u did but for the tree view itself i think it's very easy
I am so impressed... I looked at your youtube home page and discovered you have tutorials on WPF, C# AND!!!!!! SOLIDWORKS API.... I am blown away...because... I love the way you tutor and NOW you can tutor me in the 3 subjects I need most... WPF, C# and Solidworks Api.... WTF!!!
Awesome. Yeah the SolidDNA stuff is fun I want to get back to doing more of it, it is just the WPF fans took over and it was way more popular. I'll do more SolidDNA shortly though
Try Marcel Kelm's comment above yours atm: "Mention: VS2019 doesn't set the build action for images by default, so if you want to use images [...] you have to set the build action from "none" to "resource" for this image [...]"
Hi Luke, I don't understand why, when I put var name = MainWindow.GetFileFolderName(path); in the breack point, I was specting a blanck string... but it returns me, the string in the path... And my drives, looks like folders.... What could i do?
The FileFolderName I made to return the folder name if its a folder, and a file if its a file. Not the parent. If you send me your code to contact@angelsix.com and point out your issues I can help.
Hello AngelSix, Do you have any example how to implement TreeView w/ CheckBoxes that have the IsThreeState set to True in order to have a Toggeling of ON/OFF/MIXED? thanks in advance.
Holy shit this is hard on beginners, I feel I need 10 videos before this one. I then skipped to the 4th video in the playlist and everything was going well until you brought piece of code from this video, the customized look of the window. So now I have to pull through this one even though I don't understand half of the stuff. It would maybe be easier if you didn't include these dummy items after you presented us with the idea of how treeview should look with dummy items, I feel kinda frustrated. However your other videos are 10/10, from this playlist and other ones (I just wish this video didn't exist specifically) . You've helped a lot, big thanks! Subed!
I am trying to understand where i'm doing wrong because when i write... i get this error... the namespace prefix "(x" is not defined. i am new to WPF and C# in general and so i don't understand how to solve this. Thank you for great videos....they help alot.
i'm using VS2017 and the binding does'nt seems to work on my code. The Path=Tag after all those binding line is not recognize as PropertyPath. It is taken as an object literally.