C# WPF Tutorial #4 - Code Behind

  Рет қаралды 64,972

Kampa Plays

Kampa Plays

Күн бұрын

Пікірлер: 52
@sgt.shaggy5065
@sgt.shaggy5065 Жыл бұрын
Made a little "Don't push the button" game with this lol. Thank you for making this series.
@KampaPlays
@KampaPlays Жыл бұрын
That is awesome! Those types of button mashing games were some of the first apps I wrote myself, long time ago! :)
@eedorian967
@eedorian967 Жыл бұрын
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!
@KampaPlays
@KampaPlays Жыл бұрын
Thank you, I really appreciate that. Let me know if you have questions!
@evanmashack8242
@evanmashack8242 Жыл бұрын
You are very talented at explaining things simply.
@KampaPlays
@KampaPlays Жыл бұрын
Thanks!! 😊
@SharpTiger14
@SharpTiger14 Жыл бұрын
Hey, just came across your videos, and am loving this series so far! Thanks so much for making these!
@KampaPlays
@KampaPlays Жыл бұрын
Awesome, very glad to hear!
@htoohtoosan7648
@htoohtoosan7648 4 ай бұрын
Thank you very much. I am just a starter of studying WPF and your videos helping me alot. Easy understanding!
@wookyumkim4669
@wookyumkim4669 2 жыл бұрын
I'm soooooo happy to study with this series. Your video is so good 😆😆😆
@KampaPlays
@KampaPlays 2 жыл бұрын
Great to hear, thank you for watching!!
@zajac4817
@zajac4817 6 ай бұрын
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!
@guanchenpeng5180
@guanchenpeng5180 Жыл бұрын
Very useful and concise introduction!
@KampaPlays
@KampaPlays Жыл бұрын
Thank you!!!
@SansarNeupane
@SansarNeupane 10 ай бұрын
I am learning. Hats up to you brother, i love you
@KampaPlays
@KampaPlays 9 ай бұрын
Awesome, much love!
@MethodOverRide
@MethodOverRide 2 жыл бұрын
Really enjoying this series. I did notice in this video that your mic volume was a little low.
@KampaPlays
@KampaPlays 2 жыл бұрын
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!
@ArifBillahOnGoogle
@ArifBillahOnGoogle Жыл бұрын
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.
@KampaPlays
@KampaPlays Жыл бұрын
Glad its helpful, yes its a very different feel from web markup, especially if you are used to heavy CSS.
@mariaisabelcondealtamirano8140
@mariaisabelcondealtamirano8140 Жыл бұрын
Great series of videos !! It helped me a lot... I'm only beggining... but the explanations are very accurate.
@KampaPlays
@KampaPlays Жыл бұрын
Thanks so much, glad to help!
@grimyx86
@grimyx86 Жыл бұрын
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! 🔥
@KampaPlays
@KampaPlays Жыл бұрын
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!
@grimyx86
@grimyx86 Жыл бұрын
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 🤘
@atkbenz4416
@atkbenz4416 3 ай бұрын
Hello I have a question: Can you explain the position and de function of bool running = false; and running = !running
@MrReMiX-sf1qb
@MrReMiX-sf1qb 2 жыл бұрын
Лучший! Спасибо большое
@angeldepaz6407
@angeldepaz6407 Жыл бұрын
Amazing tutorial thanks man 🤝
@KampaPlays
@KampaPlays Жыл бұрын
Thank you!
@vertorenogaming888
@vertorenogaming888 Жыл бұрын
Wow, I have knowledge in HTML it uses almost the same property. I would be learning this thanks
@KampaPlays
@KampaPlays Жыл бұрын
Great to hear!
@charleslueker2597
@charleslueker2597 2 жыл бұрын
The commercials are twice as loud as the audio, but good info
@KampaPlays
@KampaPlays 2 жыл бұрын
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.
@64imma
@64imma Жыл бұрын
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.
@KampaPlays
@KampaPlays Жыл бұрын
Great tip. I should have done that, sometimes I autopilot and forget to 'work smarter not harder' things :)
@contasfinalcontasfinal
@contasfinalcontasfinal Жыл бұрын
9:08 cant u use switch case?
@KampaPlays
@KampaPlays Жыл бұрын
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.
@ShemuelObadjah
@ShemuelObadjah 7 ай бұрын
Excellent!
@acessogeral1537
@acessogeral1537 4 ай бұрын
Nice tutorial.
@ThatAnnoyingGuyOnTheInternet
@ThatAnnoyingGuyOnTheInternet 9 ай бұрын
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
@KampaPlays
@KampaPlays 9 ай бұрын
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.
@ThatAnnoyingGuyOnTheInternet
@ThatAnnoyingGuyOnTheInternet 9 ай бұрын
​@@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...
@KampaPlays
@KampaPlays 9 ай бұрын
@@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
@marypaul9627
@marypaul9627 Жыл бұрын
New sub here great content
@KampaPlays
@KampaPlays Жыл бұрын
Thank you!!
@mojitharanasingha9808
@mojitharanasingha9808 10 ай бұрын
Done : 2024/03/18
@thierryd519
@thierryd519 Жыл бұрын
The audio is so low that you need to be in a church to understand!
@KampaPlays
@KampaPlays Жыл бұрын
🤣 sorry about that, i turned it up at some point.
C# WPF Tutorial #5 - Grid Control for Basic Responsive Layouts
13:04
C# WPF Tutorial #3 - Getting Started with WPF
9:11
Kampa Plays
Рет қаралды 90 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
Learn Any Programming Language In 3 Hours!
22:37
Code With Huw
Рет қаралды 640 М.
The Basics of Data Binding in WPF
20:53
Tactic Devs
Рет қаралды 51 М.
WPF C# MVVM Sample Application
13:16
MpCodes
Рет қаралды 20 М.
Intro to WPF: Learn the basics and best practices of WPF for C#
1:10:34
C# WPF Tutorial #8 - Data Bindings using INotifyPropertyChanged
11:22
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 915 М.
C# WPF Modern UI Flat Design Tutorial
20:25
Payload
Рет қаралды 224 М.
Where Does Bad Code Come From?
42:21
Molly Rocket
Рет қаралды 212 М.
C# WPF Tutorial #6 - Custom User Controls
8:56
Kampa Plays
Рет қаралды 61 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН