C# Tutorial 19 WPF & XAML
HTML-код
- Опубликовано: 24 авг 2024
- Get the Code Here : goo.gl/UR6Fl5
Best C# Book : amzn.to/2iMArkU
Support me on Patreon : / derekbanas
This is the 1st of many videos about designing GUI interfaces with WPF and XAML. Windows Presentation Foundation (WPF) is used to create graphical user interfaces. Using XAML eXtensible Application Markup Language you can create the UI using XML like tags.
We'll also look at event handling, tracking mouse movements, open dialogs, save dialogs, popups, multiple layout managers and much more.
For best results take notes on the cheat sheet provided above as you watch and leave any questions you have.
Thank you to Patreon supporters like the following for helping me make this video
cottageindustriesbuild/
jaryd remillard : instagram: @distant_admiration
bugreplay.com
@kyleaisho
@thetwistedhat
vjFaLk
jaryd remillard : github.com/Yea...
I like the rapid pace of this tutorial. After 30 minutes I know enough to go and research the rest on my own. Thanks!
Thank you for the nice compliment :) I'm happy I could help
This tutorial was clear, and very easy to follow. In under 30 minutes you have a really good basic understanding of WPF and it still holds true for today! Thanks!
Thank you very much :)
I work for an ERP company. Our main product was built using WPF and we have a tool that creates XAML which is really limiting. Because of this, they created an SDK where I can't seem to get a good grip on the concept. This tutorial really helped with that model.
Also, side note, I was wondering why his voice was familiar as it turns out I was watching an algorithm video of his the other week.
Liked & Subscribed all the best to you Derek you are a good man.
WPF is probably an intense enough topic for its own separate tutorial.
I really like your videos. You explain everything clearly and typing the XAML properly
Thank you very much :)
Now I must struggle to transcribe this to F# with my feeble brain. Thanks all the same for this, really been wanting to actually make something someone can put to use without needing to work through command prompt. >.>
Good one, touches all basic things we can do with WPF, excited to see what you have covered using WPF in next ones.
Thank you :) I hope you like them
Best joke ever.
"Hello world" just for do something different 9:30
That's funny :)
Loved it, Derek. From the overall C# tutorial perspective, if you covered assemblies, JIT, signing, obfuscation, etc that would be extremely beneficial as well.
Thank you :) I'll make sure they are covered
Thank you!
*Exactly* the kind of WPF stuff i've been looking for, You're the best Derek :)
MSDN's great for showing you Hello World, Hello World in a WPF application, Then how to move the stars and planets around in the solar system using C++, But nothing in between.
Thank you :) This will be a multipart tutorial on WPF. I'll try to touch on most everything
I thought you should have covered Event before this. Basic WPF should be in 3 video not 2, page navigation user control data context data binding are essential to WPF.Advance topics MvvMEntity framework Design pattern and Best practices should be on the list. Before moving to xamarin. I belive pther viewers will agree with me
That is a good point. I'm doing my best to keep everything understandable.
Thank you
i have been looking for a suggestion like this, thank you mehn
Your tutorials are the best I've seen!
Thank you very much :)
How do you automatize this? Like classes in CSS? If you have 10 buttons and want to style them all same, you must have a way to do it in one place. Same goes for other elements on the page. How to simply declare couple of attributes, and then bind them with the elements?
Ewwie Gui - These videos have been amazing, stepped away from Visual Studio and this series has kicked me back into gear! Thanks
Thank you :) I'm very happy to hear it is helping
Hey Derek! I'm a regular viewer of yours since about 2 years, and to be honest, there isn't so much content for people like me nowadays. One of the major advantages of watching you was that a. I learnt a lot of new stuff I didn't know about before b. I could learn stuff very quickly. However, since quite some time, I feel like this isn't the case. Last 8 months or so were just really long tutorial series; Python, VB and now C#. Those are aimed only at a limited audience, it lefts out the regular viewers, as well as most randoms, and just interests people that are into a whole series like these... and those are something, that every other RUclipsr has.
What would I do with it?
I understand that you might run out of topics to cover, but I think you could just cover one-video topics in between more, there is still lots of stuff you could cover - different frameworks, templating engines, or just libraries. (some suggestions below) And instead of making numbered series, you could just make one huge video for the basics as always and then lots of independent follow-up videos on each specific topic, and you could just mention prerequisites at the beginning of the video, should there be any.
Project-like miniseries are also something that would be cool ^^
Those are just my suggestions on making the channel better, I appreciate and love your videos no matter what :)
My list of things you could cover:
Erlang, Elixir // very interesting languages that I'm trying to explore
Phoenix, Sugar // two frameworks for Elixir, with the former gaining quite a momentum
Socket.io, Koa, Hapi Sails // very popular js back-end "frameworks"
Lodash, Webpack // important JS stuff
Vue.js, React+ // top JS frameworks on the front
Sinatra + Padrino // Ruby web world further
Flask, Pyramid // Python web world further
Laravel, Slim, Phalcon // just some PHP stuff
Twig, Haml, Slim // some template engines
I think that's all, I'll write to you in comments in next videos if I have any more ideas :)
Thank you for taking all that time to write that message. I printed it out. I mainly do what I do based on the requests I get. I'm not a popular channel and I know that, so I mainly try to figure out what my top 2000 people want. I plan on making more learn in ones, but I was starting to feel like my channel was full of click bait. Yes I did my best to cover everything in one video and I think I did the best I could, but it still felt click baity so that is why I stopped. I'll do my best to cover many of the topics you mentioned. I'm also planning a big game and cross platform mobile tutorial that will start very soon. I'm just one guy trying to do my best :)
Not a popular channel? Man, your programming videos are in the top of programming vids, and you have reached way over million views on some videos, that's huge :) I understand your struggle with regular viewers, but that requires just some community-building effort. I had suggested on another video to make a community forum for example. I can help you with this as well as other stuff if you want ^^
Your videos are definitely not click-baity, there is a huge difference between those and well-made titles. You are definitely using the latter. Those and thumbnails are really crucial in getting views on RUclips, I managed to upload some really popular videos myself, years ago.
Learn-in-video is a really great, revolutionary form, which I, as well as thousands of people love. Yeah, just anyone won't be an expert in a language after those, but they give great basis for using a language. You also gave some little disclaimers, so I really don't see a problem - perhaps few people got mislead, but you've changed how so many people look at programming! That's huge! :)
man i had no idea you have wpf tutorials now i know what i am going to watch :D
thank you, I can't wait for your next video. please plan to cover passing variables between pages in application. thank you in advance.
Thank you :) I'm happy you are enjoying them
This is absolutely so worth my time. Thanks for the concise overview. Great Work.
Thank you very much :) I'm very happy I could help
To any one who got a little stuck :
Around 6:50-7:20
If it wont let you change to "sys" without a error.
Look for this line and delete it(or change it).>>
xmlns:SystemGesture="clr-namespace:System;assembly=mscorlib"
Thank you for taking the time to help :)
just to save you some time
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Hey as always GREAT TRAINING - Thanks from me and 50,000+ others ... I just gave a thumbs up because his training style is great .... and every time I here his voice it somehow reminds me of the *Lawyer* in the film "The life of David Gale" (Kevin Spacey Movie) ... : - )
Thank you very much :) I'll have to check out that movie
Its a good movie (Death Row Stuff) but for us IT Computer Consultants I think "21" (Kevin Spacey Again is great - based on a true story - MIT and Maths Students and Gambling )
Excellent tutorial Derek! Thanks for this!
Thank you :) I'm very happy to be of help
i Used to be a Java Developer but oracle has really "dropped the ball" with the language, i find C# more useful for games, Applications and even cross platform mobile app. With C# and Python I'm good for any project. these two are starting to dominate the programming world.
I agree 100%
Never look down on javascript
Badmus Kaybee
not JavaScript actual Java programming language for Android & Application development.
Ionic Nativescript and ReactNative is there for mobile users
Badmus Kaybee
I've heard good things about those frameworks, Maybe sometime in the future I will have a project that needs those framework but for now I focused on game development & d occasional enterprise jobs.
What if someone wanted to dynamically add labels at runtime, and resize the window?
textstrings i suppose?
Thanks again for the awesome tutorials, you're a great instructor Derek!
Thank you very much I do my best :)
This was very easy to follow and I have never even touched WPF until now. Kudos!
- Also, what do you think of Kotlin? I wanted to make an Android app in Kotlin instead of Java (Boilerplate code yada yada...) but the learning resources are very scarce.
Decided to follow your C# tutorial instead and experiment with Xamarin. Thanks for the videos, can't wait for more :)
Thank you :) I plan on covering Kotlin soon, but I prefer to develop apps with Xamarin
on 7:13 i am supposed to get this "show potential fixes" pop up, but i don't, what do i do?
put at the top where to other references are : xmlns:sys="clr-namespace:System;assembly=mscorlib"
Great tutorials! Best on RUclips!
Just one comment: Isn't hungarian notation outdated? Or at least not considered "good"" any longer?
Thank you very much :) I find that it makes the code easier to understand.
Thank you looking forward for your next video about wpf
It will be up Wednesday morning :)
Derek Banas good job Keep it up bro
liking the video befor I watch it 👍🏼
Thank you very much :)
Nice one thank you.
Hey Derek, honestly I'm a pretty quick study but I'm totally lost in this video. Within the first 7 minutes I've lost track of what's going on. I appreciate what you are doing but is it possible to slow down and treat some of us like complete wpf idiots, lol? Thanks!
Sorry about the speed. I have heavily commented code here that should help www.newthinktank.com/2017/03/c-tutorial-19/
Why do you run that resolution, increase the text size, and keep using zoom in and out? Why no just lower the resolution so that everything gets more readable and you'll have to zoom less. I can barely read for example the menues, plus I find the constant zooming very annoying :-(
awesome. thanks Derek
Thank you :) I'm glad you liked it
In XAML, is it possible to create an array of button with the same name but different indexes
and have them all fire the same click event with the index as a parameter?
Hi Derek, I started with xaml a while ago inside a UWP app, and I really can't help myself, my question is how would you simulate flexbox behavior (space-between, space-around).
For me, the easiest way simulating space-between is to create one more column width auto width between every grid column which creates the same effect, space-around is similar just moving the content between auto columns. For the second option, I used a stackpanel, and calculated dynamically its spacing property. The windows UI contains an uniformgridlayout which can handle item alignment for generated content, but it cant handle static xaml content. So I am wondering, is there any better solution natively?
Thank you so much for making this Derek. I have a hard time getting into WPF through books so video tutorials like this are amazingly beneficial to me. I have two questions though.
Firstly, would you consider making a tutorial on one WPF's best features: Data binding? I still haven't gotten the hang of it.
Secondly, is there any simple solution to make default buttons look less bland on WPF?
Thank you so much!
I'm happy you liked it :) Yes I'll cover all of those once Microsoft updates so VS works with SQL server 2016 and MySQL
oh boy =D I mean more like binding simple arrays to lists or binding an array of objects to a listview which use special code to derive each of the listview's elements :d Databases introduce far too much complexity D=
Do you want to add an "End" statement after this.Close() ?
how can i use the wpf projet in xamarin i am using a mac or should use another tool?????? plzz help
How do i do an input method in visual studio community 2019 like where you could put a value in a variable and use shell.sendkeys a certain amount of times you put in?
Here is an example code I had written in visual basic:
set shell = createobject("wscript.shell")
strtimes = InputBox("Enter in a value to insert characters in the character map")
If not isnumeric(strtimes) then
strtimes = InputBox ("That is not a number. Please type a number.")
end if
msgbox "After you click OK, after 5 seconds, the process will begin. (If you have typed 0 or pressed cancel, the program will do nothing."
wscript.sleep(5000)
for i=1 to strtimes
shell.SendKeys "{RIGHT}"
wscript.sleep(25)
shell.SendKeys "{ENTER}"
wscript.sleep(25)
next
msgbox "All Done!"
Great video
*EDIT: Restarting Visual Studio fixed the issue
in 20:25 you didn't type the UsersName TextBox name and intellisense isn't suggesting it for me and I can't access any element in the my GUI in code for that matter
Any idea? Please help cuz am trying to follow along
Thanks
Hey Derek, could you do a video on the Aurelia framework? It's in dire need for some good tutorials and guides.
I'll see what I can do. Thank you for the request :)
Great video, thank you 😊👏🏻
Thank you :) I'm happy I could help
Hi, Derek I love your videos ... thank you for creating quality content. I have one request for you ... can you create a c# tutorial series that contains C# learnings related to game development (Unity game engine preferably)?. Keep up the amazing work .. god bless you. :)
Thank you :) Yes a huge Unity tutorial is coming very soon
Love your videos! Whats the best Xamarin book?
Thank you :) Xamarin Mobile Application Development is pretty good amzn.to/2lQ9Ubs
I have very novice C# experience, and have to create either a web app or a windows client, would WPF be too tough to accomplish such as a task?
You shouldn't have any issues. I make a few in this tutorial
Sir can we expect a tutorial on MVVM. I have been asking for 3 times. I understand you are busy. But please do a tutorial on MVVM
Derek, a little irrelevant on a C# video but thanks for making the series on Django. Was vastly helpful. Any chance you have plans for Spring/Hibernate and Grails in the near future? Thanks again.
I've been wanting to cover Spring for a while. I hope to get to it soon
Cheers.
Why use WPF/XAML when you have the default Visual Studio GUI available, which doesn't require coding? Serious question.
You can create dynamic interfaces, transfer between desktop and the web, dynamically scale resolution, animations, etc
Hello Derek,
May I ask you why do you use x:Name=" " instead of just Name=" "?
Because using x: Name you can refer the object in code behind-file...
Thank you for the tutorial!
You're very welcome :)
Okay, I have been curious how GUI is created, as I have been learning c++ (for game dev) and c# (app dev). This video clears up so much. Is there any documentation for XAML i can look at?
I'm happy it helped :) docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/xaml-in-wpf
Thank you very much for your effort.
I'm happy to be of help :)
Thanks.
Do you plan on covering MVVM?
Yes, I'm glad you liked it :)
Hi Derek, thanks for this amazing course. It's been excellent so far. I have a problem where I'm using an Apple Mac and am using Xamarin. Which solution should I open to follow along with this tutorial?
I think you have to try to use Windows and install Visual Studio 2019 because i believe you cannot find what you are looking for without switching operating systems
Hi Derek, thanks for all your tutorials :) If I might ask; are you going to talk about ASP? (Active Server Pages) I mean; how to create a website using C#.
Thanks and good luck ;)
I'm very happy to help and yes I'll talk about ASP
Amazing, thank you :) I am programming websites in PHP (+Javascript, AJAX, HTML, CSS), but recently C# is becoming more and more popular, so I want to learn it :)
can you make a Windows form application tutorial please
Ewwie Gui
Thanks for another fun video jam packed with information!
Thank you :) I try to make the videos fun
Hi Derek,
Thanks for another awesome tutorial video but I do have a question @7:15 when changing from SystemGesture to sys inside , it didn't pop up the yellow "light bulb" to allow me fixing the error. It does show some errors such as "namespace prefix " sys" is not defined + String is not supported in a WPF project". Is there a way to fix it? And by the way, I'm using VS2015.
Thanks,
Ed
Hi Ed, Try comparing your code to the code I have in the description with diffnow.com Sorry I'm not sure what could cause that
if you are still stuck
look for this line.
xmlns:SystemGesture="clr-namespace:System;assembly=mscorlib"
and delete it.
could you please do a full c++ tutorial with gui.
Great lecture Derek, again ! Question, do you know of any free xaml cheat sheet with all the different command and parameters available? Even thought VS gives you suggestions as you type, I think the cheat sheet could be useful to see what is available as a whole. Thanks in advance.
Thank you :) I have an XML series and in the description for each video is a link to a cheat sheet that may help ruclips.net/video/tAN-1xUsftg/видео.html
Thanks a lot Derek, will definitely take a look at it !
Awesome! Thanks!
Thank you :)
Question: how do you set up those automatic new lines in Visual Studio, so I don't get the horizontal scroll in my code?
Turn on line wrap
Derek Banas
Could you please, please, please, please tell me which piece of software do you use to zoom & pan while recording tutorials on Windows. I've tried many but all of them render pixelated zooms. Please help me out. Thanks.
Fantasterrific
Nope, if you look closely (1:10-1:18 for example) you can see two cursors everytime he zooms and pans that can't happen in post production editing. Post production editing takes up too much of time & effort.
I'm using the zoom feature on MacOS. Sorry I don' know of anything like that on Windows
Derek Banas
But this video has a Windows start button in the corner, Windows taskbar etc, wasn't this video recorded on Windows?
I'm running MacOS and Windows 10 on my Mac
Fantasterrific
I don't think Derek does that.
Coz there's no way of using the tools of the host OS inside the virtual machine.
For instance in VMware we got to use Ctrl+Alt key combo to come out of the VM OS and into Host OS so as to use any app in host OS (here mac)
So if Derek was in VM Windows, in order to zoom he would have to press Cmd+Alt to come out of the VM, then press another keyboard shortcut to toggle zoom&pan option on, then when he clicks back into the VM Windows the VM Windows would take up the whole screen thereby canceling out the Mac's Zoom.
I have tried that with Microsoft's Zoomit app on Windows running a VM Redhat, it doesn't work
Another point to be noted is that there wouldn't be two cursors everytime he pans
You are a genius, how do you learn? you seem to know everything :D
I promise that I'm not that smart. Watch my video game puzzle videos to see an example of that. This is how I learn ruclips.net/video/VpqXCeTfe0Y/видео.html
Are you covering async and diffrence from threads next?
That is coming
Hey, thank you for videos! Can you make video tutorial Qt or Git?
You're very welcome :) Here is my Git tutorial ruclips.net/video/r63f51ce84A/видео.html
What is the thing that makes a new line when your code gets to the end of the current line?
I have line wrap turned on
thank you)
How did you get designer working. Its giving me an error every time I try to access it
Are you using Visual Studio 2017
Derek, I'm having a lot of headache to set up my enviroment to start up coding with xamarin...
I've tried everything possible, and it seems impossible to get the things up and running...
Always showing up errors when I try to run my welcome to xamarin start up project, and during install, it shows SDKs and other things that it's needed to complete the installation... I've done everything, but to update the xamarin to v4 always an error.
I've read articles, youtube videos, documentation, and gooooooosh...
so, that why I'm going here and asking for your help... to make a video and solve my pain, and I'm certainly sure that there's a lot of users going through same issues... I've formated my pc 4x times to install everything from beginning, I don't know more what to do, where to check or update, which folder option to install SDK, etc... I'm simply upset.
I'm sorry you are having so many problems. What OS are you using? If you are on Windows, why not use Visual Studio?
Derek Banas I'm already using Windows, and also VS Community 2015... hope VS2017 solve these troubles.
I'm sorry, but almost ALL of these training videos jump write into coding in XAML, and totally ignore the WYWIWYG editor. A newbie would never know all the commands you pull out of your hat -that's what the property window is for. It's like you have a moral aversion to NOT coding by hand. IMHO, these should START with Drag-n-Drop, and THEN drop into XAML.
do you have any tutorial about "audio signal recording?" in java or python or anything?
Can you give me an example of what you are trying to do?
All I need to do is record an audio just for 3 seconds and save the data in an integer array (so that I can plot it later and do some analysis such as FFT). I actually have found the solution written in java, but I don't think it's efficient. I can't find anyone explain codes better than you do.
Um, nothing on Windows Forms Applications?
Why would anyone use it?
TheMassesAreAsses Because..... They do....
Thank you Sir...
I'm very happy to be of help :)
It is built into MacOS. I'm not sure if you can do it with Windows
Ewwie Gui, great as usual.
Thank you for that :)
Wow! I thought WPF was dead? Are they revamping it ?
Well Windows Forms is far from being dead it is still usefull for one use apps read quick and dirty apps.
No WinForm is not dead. You may be thinking about Silverlight. Back in 2014 there was very little life in WPF, so much that people were finding out that the WPF team at MS disbanded. If you google "Is WPF dead" you will find a lot of talk about very little movement in WPF. Along with it being abandoned for WinRT (now dead lol). But I'm happy if WPF is coming back from idle development.
nice sir
Thank you :)
thank you :D
It is my pleasure :)
How much far from Game making??
A couple weeks. Sorry it is taking so long. Once I start it I'll make a ton of videos over many months.
where do you learn to code?
I made this learn to program tutorial ruclips.net/video/nwjAHQERL08/видео.html
I like it. :D
Thank you :)
*Do Not Read My Name*
That's funny :)
Ewie Gui!
Thank you for watching the whole video :)
is this visual studio 2017 ?
Yes VS Community
is it possible to download it for free ? and what the difference between 2015 and 2017 ?
Yes the Community version is free. 2017 is way more stable and faster
What about Rust video(s)? I for one, would love to see those. I feel like when Rust fully matures, it's going to become mainstream.
Here is my Rust tutorial ruclips.net/video/U1EFgCNLDB8/видео.html
Oh! My apologies. I thought I had searched thoroughly enough ;). Thanks!
This tutorial moved so fast that I can't understand it. Seriously. There are no good wpf tutorials anywhere. Their all either too fast paced to understand or so slow paced that I want to pull my hair out after 10 minutes of fucking nothing happening.
Ewwie Gui :D :D :P
Best tutorial series!
Thank you :) I'm happy it helped
More like html than c# :P
Fart 19 :-)
your going too fast in this video and not explaining anything properly and just throwing everything at us
I personally don't like Derek's tutorials as they are a little bit too quick and don't go deeper in the explanation. I would rather have 2 hour WPF tutorial than this.
Yo...EWWIE GUI
Thanks for doing that :)
ewwie gui
ewwie gui :-)
Thank you for doing that :)
Ewwie Gui
Thank you for that :)
GUI Interfaces? Are you serious or was that a joke?
What are you referring to?
Gabriel Jones "as as soon as possible"
As Gabriel said, The 'I' in GUI stands for 'Interfaces', so it's redundant to say "GUI Interfaces". It's like saying "RAM Memory" or "RIP In Peace".
Sir can we expect a tutorial on MVVM. I have been asking for 3 times. I understand you are busy. But please do a tutorial on MVVM