You teach way better than online paid courses! So glad I found your channel cuz ill make this playlist my number 1 to go to learn wpf. Thank you for making these vids, may your channel grow bigger!
Coming from web dev, thigns are quite uneasy for me (you know plain HTML, CSS -> XAML, XML stuff). But you make things very easy to understand. Thank you.
Hey man 👋, why would you make the variavle "bool running = false;" in the class and not in the MainWindow() or in the event handler? Also why would u put "running = ! running;" outside of the loop in the event handler and not in the class? I am still new to this and I am so confused, do I just not understand scope logic? Will I find out in later videos? Why am I missing this logic here? Greatly appreciate this video series! 🔥
Hey! Yes, that is scope you are referring to. Q: why would you make the variavle "bool running = false;" in the class and not in the MainWindow() or in the event handler? A: we need to be able to save the variable state of running even after the event handler has completed. if we put it in the event handler, it would be destroyed when the event handler completed executing (goes out of scope). by putting it in the class, we are able to set it, and it persists as long as the class exists, so any time the event handler runs, we can check it. Q: Also why would u put "running = ! running;" outside of the loop in the event handler and not in the class? A: running = !running is logic toggling the boolean - we can't put logic like this in the class itself, because it would have no method of execution. it belongs in the event handler, because we want to toggle that variable every time that event handler runs I don't have a specific video on scope - but I do have a beginner C# tutorial series that goes over a lot of the basic details of the language itself, that might be helpful to go over before diving deeper into WPF. Hope this helps!
8:00 It seems you can easily rename these things by going into the xaml.cs file, and doing the renaming there, rather than doing it in the xaml file THEN going to the xaml.cs file.
Great series can't wait to continue following, i come from strictly SWift/SWiftUI, so I don't know the idiosyncrasy of Microsoft/C#/Visual Studio and your video helping connect dots. Best Regards!
Question: I have Then I add the button in code behind: Area1.Children.Add(newButton); //this makes sense, adding a child to "Area1" Canvas.SetLeft(newButton, 500); // *why do I have to reference "Canvas" instead of "Area1"?* Area1.SetLeft(newButton, 500); //this would make sense but doesn't work
It's because SetLeft is a static method of the Canvas class - so it does not need to be called from an object of that class, but is called from the class itself. Can be confusing at times, especially mixing the object itself in.
@@KampaPlays Thanks for the answer, that actually makes sense (even though it brings up more questions): How does it differentiate when I have multiple canvases? I know it does (tested it), but how does it know which canvas I'm talking about? For example (assume I have 2 Canvases, Area1 and Area2): Area1.Children.Add(newButton); Area2.Children.Add(newButton2); Canvas.SetLeft(newButton, 500); // which canvas are we talking about? Canvas.SetLeft(newButton2, 50); // same question again And if it finds the correct canvas "under the hood" (like getting parent of the passed element and going from there), why not just use newButton.setLeft(500); which could find the parent as well but would be more intuitive. The way it works just seems convoluted to me so, I would like to know the logic behind it...
@@ThatAnnoyingGuyOnTheInternet All good questions. - It knows which canvas because it can find the parent of the given button (as you mentioned "under the hood"). - You wouldn't want to do newButton.SetLeft(500) because then button would require attributes and methods like this for every single container it may or may not belong to (cumbersome and confusing) - It *could in theory* do canvasObject.SetLeft(button, 500) and store information that way specific to the Canvas object, but instead: - WPF/XAML use things called attached properties and dependency properties - so this is most likely a static method on the Canvas class creating one of those properties, and attaching it to your button. It makes things very modular, very reusable, very flexible, and very hard to understand sometimes 🤣 learn.microsoft.com/en-us/dotnet/desktop/wpf/properties/attached-properties-overview?view=netdesktop-8.0
Sure, would work the same. In my opinion for a boolean check, if-else is clearer to read. I usually use switch when there are several states/options to check.
Made a little "Don't push the button" game with this lol. Thank you for making this series.
That is awesome! Those types of button mashing games were some of the first apps I wrote myself, long time ago! :)
You are very talented at explaining things simply.
Thanks!! 😊
You teach way better than online paid courses! So glad I found your channel cuz ill make this playlist my number 1 to go to learn wpf. Thank you for making these vids, may your channel grow bigger!
Thank you, I really appreciate that. Let me know if you have questions!
Hey, just came across your videos, and am loving this series so far! Thanks so much for making these!
Awesome, very glad to hear!
Thank you very much. I am just a starter of studying WPF and your videos helping me alot.
Easy understanding!
I'm soooooo happy to study with this series. Your video is so good 😆😆😆
Great to hear, thank you for watching!!
Very useful and concise introduction!
Thank you!!!
A little late to the party but I just love the approach. I'm loving this tutorial and I'm making the most of it!
Really enjoying this series. I did notice in this video that your mic volume was a little low.
I'm glad!!! And uh oh, because I've recorded pieces and parts for like 5 more videos.. ☠ Thanks for letting me know, I will turn it up!
Лучший! Спасибо большое
I am learning. Hats up to you brother, i love you
Awesome, much love!
Coming from web dev, thigns are quite uneasy for me (you know plain HTML, CSS -> XAML, XML stuff). But you make things very easy to understand. Thank you.
Glad its helpful, yes its a very different feel from web markup, especially if you are used to heavy CSS.
Great series of videos !! It helped me a lot... I'm only beggining... but the explanations are very accurate.
Thanks so much, glad to help!
Wow, I have knowledge in HTML it uses almost the same property. I would be learning this thanks
Great to hear!
Excellent!
Amazing tutorial thanks man 🤝
Thank you!
Nice tutorial.
Hey man 👋, why would you make the variavle "bool running = false;" in the class and not in the MainWindow() or in the event handler? Also why would u put "running = ! running;" outside of the loop in the event handler and not in the class?
I am still new to this and I am so confused, do I just not understand scope logic? Will I find out in later videos? Why am I missing this logic here?
Greatly appreciate this video series! 🔥
Hey!
Yes, that is scope you are referring to.
Q: why would you make the variavle "bool running = false;" in the class and not in the MainWindow() or in the event handler?
A: we need to be able to save the variable state of running even after the event handler has completed. if we put it in the event handler, it would be destroyed when the event handler completed executing (goes out of scope). by putting it in the class, we are able to set it, and it persists as long as the class exists, so any time the event handler runs, we can check it.
Q: Also why would u put "running = ! running;" outside of the loop in the event handler and not in the class?
A: running = !running is logic toggling the boolean - we can't put logic like this in the class itself, because it would have no method of execution. it belongs in the event handler, because we want to toggle that variable every time that event handler runs
I don't have a specific video on scope - but I do have a beginner C# tutorial series that goes over a lot of the basic details of the language itself, that might be helpful to go over before diving deeper into WPF.
Hope this helps!
This helps a lot, I understand the logic and reasoning now. Thanks for taking the time to respond to my comment, have a good one! @@KampaPlays 🤘
The commercials are twice as loud as the audio, but good info
Yikes, thanks for letting me know, hate when they max out ad volume. Will try to up my level so it won't be so jarring.
New sub here great content
Thank you!!
8:00 It seems you can easily rename these things by going into the xaml.cs file, and doing the renaming there, rather than doing it in the xaml file THEN going to the xaml.cs file.
Great tip. I should have done that, sometimes I autopilot and forget to 'work smarter not harder' things :)
Great series can't wait to continue following, i come from strictly SWift/SWiftUI, so I don't know the idiosyncrasy of Microsoft/C#/Visual Studio and your video helping connect dots. Best Regards!
Awesome to hear!! Thank you for watching and let me know if you have any questions!
Question:
I have
Then I add the button in code behind:
Area1.Children.Add(newButton); //this makes sense, adding a child to "Area1"
Canvas.SetLeft(newButton, 500); // *why do I have to reference "Canvas" instead of "Area1"?*
Area1.SetLeft(newButton, 500); //this would make sense but doesn't work
It's because SetLeft is a static method of the Canvas class - so it does not need to be called from an object of that class, but is called from the class itself. Can be confusing at times, especially mixing the object itself in.
@@KampaPlays Thanks for the answer, that actually makes sense (even though it brings up more questions):
How does it differentiate when I have multiple canvases? I know it does (tested it), but how does it know which canvas I'm talking about? For example (assume I have 2 Canvases, Area1 and Area2):
Area1.Children.Add(newButton);
Area2.Children.Add(newButton2);
Canvas.SetLeft(newButton, 500); // which canvas are we talking about?
Canvas.SetLeft(newButton2, 50); // same question again
And if it finds the correct canvas "under the hood" (like getting parent of the passed element and going from there), why not just use
newButton.setLeft(500);
which could find the parent as well but would be more intuitive. The way it works just seems convoluted to me so, I would like to know the logic behind it...
@@ThatAnnoyingGuyOnTheInternet All good questions.
- It knows which canvas because it can find the parent of the given button (as you mentioned "under the hood").
- You wouldn't want to do newButton.SetLeft(500) because then button would require attributes and methods like this for every single container it may or may not belong to (cumbersome and confusing)
- It *could in theory* do canvasObject.SetLeft(button, 500) and store information that way specific to the Canvas object, but instead:
- WPF/XAML use things called attached properties and dependency properties - so this is most likely a static method on the Canvas class creating one of those properties, and attaching it to your button. It makes things very modular, very reusable, very flexible, and very hard to understand sometimes 🤣
learn.microsoft.com/en-us/dotnet/desktop/wpf/properties/attached-properties-overview?view=netdesktop-8.0
9:08 cant u use switch case?
Sure, would work the same. In my opinion for a boolean check, if-else is clearer to read. I usually use switch when there are several states/options to check.
Done : 2024/03/18
The audio is so low that you need to be in a church to understand!
🤣 sorry about that, i turned it up at some point.