C# WPF Tutorial #19 - Opening Custom Windows with Show and ShowDialog
HTML-код
- Опубликовано: 14 июн 2024
- How to create and open custom application windows both normally and modally with Show and ShowDialog. Going over basic use cases for each, and implementing a custom modal with some nice to have features.
Happy Coding!
Chapters:
0:00 Setup
0:13 Creating WPF Windows
1:26 Opening Windows
2:30 Show vs ShowDialog
2:59 Show Behavior
3:42 ShowDialog Behavior (Modal)
4:17 Show Use Case
6:20 ShowDialog (Modal) Use Case
7:10 Returning Data from Modal
9:31 WindowStartupLocation
10:39 Window Opacity for Focus
11:29 Next Up - Наука
Very helpful video. Appreciate these WPF tutorial videos.
Thank you, glad to help!!
I can see this channel going places... Thank you for a brilliant tutorial...short and sweet
Thanks so much, glad it is helpful!
Hey, if you're strictly adhering to MVVM architecture, is it better to instantiate/show windows in the code-behind, or in the ViewModel? From what I understand, putting view-related logic in the ViewModel is a violation of the MVVM pattern, but there's a lot of conflicting answers to this online.
Also, congrats on the great tutorial.
Thanks!
Lots of conflicting answers on this one is the truth -- this is a very touchy subject with a lot of people. My opinion (take it with a grain of salt) is if you are strictly adhering to it, then you should not, but instead use something like a window service interface/dependency injection to achieve full separation.
Further opinion (more grains of salt): I rarely advise projects to adhere extremely strictly unless the project is massive/lots of moving parts (easier on maintenance), or uses a large varied or inexperienced team (easier on peer review/prevents laziness). As long as you succeed in the separation of concerns in both dev and test - it is very beneficial. Strict rules (like zero code behind) generally just slow down development and introduce unnecessary complexity.
Hope this helps.
Merci pour vos didacticiel très explicites
Thank you!!
Nice and Fine
Thanks!!
That was a wonderful video. You helped me a lot. Can you teach how to create some mvc model? To change main windows with a controller? using a 'panel' or directly in the 'grids'. ❤
Thank you, I'm glad it helped!
In just a few videos i will be starting a set of videos on MVVM. It's extremely close to MVC, except it uses a "view model" as a controller, and fits really well with WPF.
@@KampaPlays this is wonderful! So I'll be waiting anxiously for the next videos
Could you please organise some virtual live session's as well so that people who have any doubts after video can ask
I would really like to do this, but at the moment I don't have the time. Currently work is keeping me so busy that I'm a bit behind on creating the videos themselves, but maybe once things calm down I can do something like this. Thank you for the suggestion, and for watching!
What is the difference between "x:Name" & "Name" attributes ?
Name is a property on a class in .NET.
x:Name is a XAML-specific attribute that all elements can have.
Functionally, they are basically the same thing. I generally only use x:Name when Name isn't available, but that's just me.