WPF in .NET Core and MVVM Navigation - FULL STACK WPF (.NET CORE) MVVM #3

  Рет қаралды 53,841

SingletonSean

SingletonSean

Күн бұрын

I finally set up the WPF project for the Simple Trader front-end. I setup the project in an MVVM fashion, create a very simple navigation control, and setup navigation between view models.
In this series, I walk through the development of a WPF application from the database layer to the UI layer.
SOURCE CODE: github.com/SingletonSean/Simp...
FULL PLAYLIST: • Full Stack WPF MVVM

Пікірлер: 142
@Psymun747
@Psymun747 4 жыл бұрын
Dude this is great, it's really useful to see MVVM set up *without* a precooked framework. Helped me get my head around what's happening in the code. Keep it up man, thanks for your great work
@SingletonSean
@SingletonSean 4 жыл бұрын
Thanks Simon, glad I could help! I agree, seeing the process without a framework really solidifies understanding and even helps if you ever feel the need to use a framework in the future.
@asoftraiden
@asoftraiden 3 жыл бұрын
@@SingletonSean ok I understood the no framework approach, now please suggest a fast framework approach, what do you think is best framework to help me precook MVVM apps???
@Babaelow
@Babaelow 3 жыл бұрын
@@asoftraiden Tim Corey does that quite nicely. Although I came here FROM Tim Corey to see it actually done without framework. There is the framework Caliburn.Micro, which has just been outdated but is used quite a few times.
@bret-bacon
@bret-bacon 3 жыл бұрын
This is amazing, I'm developing a POS system from scratch solo and the framework issue was the next biggest issue I've had since database design, language choice and library collections. I'll be glad to get away from too many external dependencies. You've helped alot on my MVVM journey. I'll keep watching your channel and supporting you when I have the free time. Thanks!
@cheeyang4177
@cheeyang4177 4 жыл бұрын
Great tutorial series so far. Looking forward to your next video.
@SingletonSean
@SingletonSean 4 жыл бұрын
Glad you're enjoying it Chee! I'm excited to see the final product for this application.
@enriqueduquegarrido6132
@enriqueduquegarrido6132 2 жыл бұрын
¡Por ahora va divino! estás uniendo en un sólo proyecto un montón de ideas.
@enriqueduquegarrido6132
@enriqueduquegarrido6132 2 жыл бұрын
La media hora más intensa de mi vida, menos mal que habla despacio.... Impresionante despliegue de conocimiento.
@sc100200090
@sc100200090 3 жыл бұрын
Excellent!!! Finally a source I found to be launching right from the .Net Core and besides guiding and introducing CRUD via Interface in the last video surely leading towards deep understanding of the rich XAML based app of WPF! Awesome for sure! Regretfully due to lengthy working hours haven't been able to check out further ahead but can't wait to do so. Specially is a great source of learning while even changing names, styles, and types! Thanks again SS!
@SingletonSean
@SingletonSean 3 жыл бұрын
Thanks Faraz! Keep up the good work.
@RamonWilliams
@RamonWilliams 3 жыл бұрын
This is the clearest explanation i've seen on navigating user controls. seriously much appreciated for this. I would've probably poorly implemented one of my projects if it wasnt for this series
@SingletonSean
@SingletonSean 3 жыл бұрын
Awesome Ramon, glad it helped potentially save some time!
@norbertbraun9718
@norbertbraun9718 3 жыл бұрын
The best tutorial about Wpf MVVM I've seen till now and I've seen several. Thanks for that helped me a lot.
@ElizabethGillen
@ElizabethGillen 3 жыл бұрын
Great tutorial!! Exactly what I was looking for!
@asoftraiden
@asoftraiden 3 жыл бұрын
I love WPF, I like your way of talking and your voice, cool.
@SingletonSean
@SingletonSean 3 жыл бұрын
That's great to hear Asoft, thank you!
@mb-ql1gb
@mb-ql1gb 4 жыл бұрын
Great video, wonderfully explained, very useful for beginners! You explained lots of things which are very usefull, the viewer get a great overview how most needfull stuff is done to complete the whole job.
@SingletonSean
@SingletonSean 4 жыл бұрын
Thanks mb! Glad to hear my explanations are helpful.
@mooi2785
@mooi2785 2 жыл бұрын
Excellent Tutorial series with this MVVM framework.
@erwinruoff8713
@erwinruoff8713 2 жыл бұрын
Thanx for this great tutorial. It helped me lot to find my way through the WPF-MVVM-Jungle!
@justjustIT
@justjustIT 3 жыл бұрын
I am watching a video to learn MVVM in my 2nd year of WPF development. The MVVM pattern was difficult but surprising.
@Me_llamo_Lucifer
@Me_llamo_Lucifer 4 жыл бұрын
This tutorial series is exactly what i needed! Its been very difficult to find any new videos on WPF using .net core so this has been a huge help. Great job showing us how to us MVVM without Caliburn.Micro especially since Caliburn.Micro is not optimized for .net core. Your custom MVVM framework saved the day.
@SingletonSean
@SingletonSean 3 жыл бұрын
Glad I could help Sean! I agree, not much out there on WPF in .NET Core. Luckily, WPF in .NET Core isn't too different than it was in .NET Framework in my opinion. I've never used Caliburn on a large project, but unfortunately it seems the project has been archived.
@laljigoti3711
@laljigoti3711 4 жыл бұрын
great series!! so many things to learn...love it man
@SingletonSean
@SingletonSean 4 жыл бұрын
Thanks Lalji, glad you're learning and enjoying!
@daliangilbert
@daliangilbert 2 жыл бұрын
Great Job @SingletonSean!
@eyesuskirstos
@eyesuskirstos 3 жыл бұрын
even easier than the extensions, thanks!
@ozkanb
@ozkanb 3 жыл бұрын
you definitely have talent in teaching. Nice work and keep it up.
@SingletonSean
@SingletonSean 3 жыл бұрын
Thank you for the kind words Ozkan, more on the way of course!
@josbexerr5166
@josbexerr5166 4 жыл бұрын
Gracias Mister Sean, excelentes trucos de programacion
@parko1965
@parko1965 2 жыл бұрын
Awesome series I'm using this with WinUI 3.
@erbhaveshjadav5726
@erbhaveshjadav5726 3 жыл бұрын
Great..work
@fzuray
@fzuray 4 жыл бұрын
good tutorial, thanks shawn
@iancarr3923
@iancarr3923 3 жыл бұрын
I am starting out on wpf with experience of WinForms, sql server and .NET. Your videos are very helpful.
@SingletonSean
@SingletonSean 3 жыл бұрын
Thanks Ian, best of luck on your WPF journey!
@0x42NaN
@0x42NaN 4 жыл бұрын
thank you so much it really helps me with my projects
@SingletonSean
@SingletonSean 4 жыл бұрын
No problem Sharkyy, best of luck on your projects.
@ElTioDev
@ElTioDev 3 жыл бұрын
exelente video lo entendi bien y pense que mi ingles era malo te entendi perfectamente deseo migrar mis proyectos a mvvm. gracias buen hombre
@abdullahyavas275
@abdullahyavas275 3 жыл бұрын
Thank you!
@serkiat1
@serkiat1 3 жыл бұрын
This helped me finally get my head round MVVM, after a couple of years playing around with it! Many thanks indeed. I have a different scenario to solve for whereby I only need a single instance of each view and its view model (so as not to recreate them each time its associated button is pressed). I have therefore modified your pattern by instantiating the view instances within, and stored as properties of, the main view model and also binding the content control to a "selectedview" property. It all works well but I felt that it's not right since I am making the view model aware of the views, albeit just superficially. If you have any thoughts or comments about this, I would be all ears. Thanks again.
@feelingeverfine
@feelingeverfine 4 жыл бұрын
Keep it up thanks!
@SingletonSean
@SingletonSean 4 жыл бұрын
David Thank you David! Working on a new episode for the latter part of this week. Glad you're enjoying.
@FuzzyDPozzy
@FuzzyDPozzy 3 жыл бұрын
Hey sean at 2:51 in the app.xaml.cs class can we use dependency injection principle? the dependency principle tells you not to use the "New keyword" so i am wondering what alternatives there are?
@Galal0110
@Galal0110 3 жыл бұрын
Great video. May I ask why you didn't use a tab control instead of going through the hassle of creating a navigator with radio buttons? Thanks!
@marilu9138
@marilu9138 3 жыл бұрын
why i cant open this proyects? wich visual studio version do i need to use to open them?
@gregh2327
@gregh2327 4 жыл бұрын
This is absolutely brilliant! This entire series has been very helpful. Especially rolling your own MVVM. Now to the question: You created a faux TabControl using radio buttons. I'm wondering why you went that way over just using the built-in TabControl.
@SingletonSean
@SingletonSean 4 жыл бұрын
Thanks Hiro! I've never used the TabControl, but it seems like it would be a feasible solution. I think I've been scared of TabControls because it looks nasty without styling (opinion). I'm interested in checking that out and playing around with styling. Thanks for the tip!
@fatihkundak6754
@fatihkundak6754 3 жыл бұрын
Great video, thanks. I want ask a question. We do not have references in the 85th second of the video, are they necessary?
@badboy13592
@badboy13592 2 жыл бұрын
Hi Thanks for the great tutorial. I just have a question at video time 18:11. How did the public enum property ViewType was detected for you without any namespace importing? I see it just inherits from ICommand but not INavigator (where you defined ViewType as enum). When I see your source code it also does not use namespace of INavigator but it just uses folder name space. I am really sorry if this question seems to be silly as beginner.
@erbhaveshjadav5726
@erbhaveshjadav5726 3 жыл бұрын
Thank you so much and please make a series on 'WPF Asp.net core MVVM'
@SingletonSean
@SingletonSean 3 жыл бұрын
More ASP.NET coming soon! An ASP.NET backend with an MVVM WPF frontend is a great desktop development stack. Thanks for watching Er Bhavesh.
@henriquefr4543
@henriquefr4543 3 жыл бұрын
The navigation works pretty well, but every time I click on Home or any other button on the navigation menu, I get a new instance of View and ViewModel. I want just one instance during the whole application lifetime of each View and ViewModel. How can I do this?
@myti1617
@myti1617 5 ай бұрын
Hello, please prepare a training list of this model. Especially in the case of accounting or management software. Thankful
@SHUJA837
@SHUJA837 3 жыл бұрын
Very good and thank you so much for sharing this great tuto. Quick question, how can I set a default View onload?
@DriveU836
@DriveU836 3 жыл бұрын
Question: What happens or what should be done to accommodate a flow; 1. A Splash Screen that waits for some background tasks to be completed 2. Login Screen thereafter -> Registration Flow -> Back to Login screen (This has been explained in your video series) 3. Thereafter MainWindow My biggest challenge as of now is to understand this flow
@wayneunited59
@wayneunited59 3 жыл бұрын
love the videos got a bit confusing around minute 18 when you started using the Icommand and jumping between classes and interfaces.
@RobinRana88
@RobinRana88 3 жыл бұрын
0:47 In latest version of 2019 , Now Microsoft has renamed the template name (wpf .net core) to just (wpf .net) which was confusing for me, to find it. Also by default it is targeting old version of .net core i.e 3.1 which can be changed to (net5.0-windows) via project properties.As this is the latest version for now
@SingletonSean
@SingletonSean 3 жыл бұрын
Good point Robin, I was recently confused at the template name for .NET 5 as well. I would've expected it to say something like "WPF (.NET 5)". I suppose Microsoft omits the 5 since .NET 5 is the new norm.
@rodfalanga3770
@rodfalanga3770 3 жыл бұрын
Enjoying this series, thank you! Got a couple quick questions. First, how did you duplicate lines of code so quickly? Second, how did you generate the constructor for UpdateCurrentViewModelBase that takes an INavigator argument so quickly?
@SingletonSean
@SingletonSean 3 жыл бұрын
Great to hear Rod! For duplication, I usually just use CTRL + C, CTRL + V with nothing selected on the line (I think you can also just use CTRL + D?). For quickly generating constructors, I highlight all the fields/properties that I want to take through the constructor, then use CTRL + ., and then select generator constructor. Constructor generation is a bit quirky on anything under VS 2019, if you're using an older version.
@johnnyserup5500
@johnnyserup5500 2 жыл бұрын
You should have created a unit test project and tested the CRUD functionalities, and perhaps showing the benefit of dependency injection
@james90902
@james90902 4 жыл бұрын
At 10:27 you seem to be using a shortcut to duplicate the current line down one, how do you do that? I tried ctrl+d / ctrl+ down arrow but couldn't figure it out. Unless you're just super fast & copy/paste of course & i'm being stupid :D
@SingletonSean
@SingletonSean 4 жыл бұрын
Hey James, after looking at the instant replay, it looks like a fast copy and paste. With my VS setup, by default I can press ctrl+c with nothing highlighted and it will copy the entire line. Then, I press ctrl+v and it pastes the entire line. You can also do ctrl+x to cut (remove and copy) an entire line. I don't consider myself a pro with key bindings, but those are some of my favorites.
@ozkanb
@ozkanb 3 жыл бұрын
After watching this a second time. What is your opinion about the Prism library, would you use the Prism library and forget about all the hassle around binding Views to ViewModels and just use the ViewModel Locator of the Prism library? And also: what about Dependency Injection?
@SingletonSean
@SingletonSean 3 жыл бұрын
Hey Ozkan, I've never built more than a simple application with Prism, but I have heard lots of positive feedback regarding the framework. I feel comfortable without a framework, and every enterprise project I've ever worked on has not used a framework. As for dependency injection, that is implemented later in the series. Stay tuned :)
@UnknownMoses
@UnknownMoses Жыл бұрын
The NET 6 SDK is in the installer for vstudio 2022 not sure about 2019 and older core frameworks.
@SingletonSean
@SingletonSean Жыл бұрын
Hey realmoses1! That'd make sense, probably need the new vstudio
@leninguevara161
@leninguevara161 4 жыл бұрын
Great Video! But how would I do it with buttons inside of the Views instead of the NavigationBar? E.g. View1 has a button that's supposed to load View2. This doesn't work for me. I can load any View from MainViewModel but no View from inside another ViewModel. Both MainViewModel and View1ViewModel have an INavigator that is = new Navigator() but CurrentViewModel only updates when the Command is called from MainViewModel.
@SingletonSean
@SingletonSean 4 жыл бұрын
Thanks for watching! For your navigation question, do all your view models share the same Navigator instance? That is, you should only instantiate one Navigator for your entire application if you want to control the current view from anywhere. Otherwise, you will update the view of a Navigator that the rest of the application does not know about.
@leninguevara161
@leninguevara161 4 жыл бұрын
@@SingletonSean Actually no. It's always a new instance. I haven't thought about that. I'll try to use just one instance then. Thanks for your answer!
@xatazch
@xatazch 3 жыл бұрын
You are creating a new viewmodel everytime you click a button. Will the old Viewmodel be disposed? i have a timer (System.Windows.Threading.DispatcherTimer) running in one of my viewmodels so i need to clean that one up. any ides of how to solve this?
@SingletonSean
@SingletonSean 3 жыл бұрын
Hey Pierre, I've run into this issue before with needing to unsubscribe my view models from events to prevent memory leaks. I would recommend implementing some kind of overridable Dispose method on your base view model (could be IDispoable interface). Then, call Dispose when you switch view models.
@xatazch
@xatazch 3 жыл бұрын
@@SingletonSean Thx good ide.
4 жыл бұрын
Hi Sean! really great tutorial, I watched them all in a row :) Can I ask you how would you implement a master-detail navigation? The most logical solution to me is to pass the selected model (or at least its id) in the constructor of the DetailViewModel but I can't figure out how... In other words, I would like to understand how to share data between ViewModels! Thanks, and keep it up with your really helpful videos!
@SingletonSean
@SingletonSean 4 жыл бұрын
Hey Sebasthian, thanks for watching and that's a great question. I find myself facing this a lot in personal projects. Unfortunately, I don't have a specific example. Usually, I'll have the master view model pass data to the detail view model, and then have the detail view model raise events that the master view model can subscribe to in order to send data back to the master. It's pretty complex and there's a few ways to do it, so hopefully I'll implement an example in this series :)
@jeffnichols4578
@jeffnichols4578 4 жыл бұрын
SingletonSean - great question and response.
4 жыл бұрын
@@SingletonSean Thanks again, I'll stay tuned to this series then :)
@pandinor3358
@pandinor3358 4 жыл бұрын
Thanks for that great tutorial. But I have a question to navigating within a mvvm pattern. Whenever you click one of these radioButtons you always create a new ViewModel (HomeViewModel or PortfolioViewModel). I took your example and put a textbox on each View. How would I manage to keep my text in that textbox after navigating to another view? I always run into that issue to have an empty textbox due to the creation of a new ViewModel. Thank you !!!
@SingletonSean
@SingletonSean 4 жыл бұрын
Thanks Pandinor! That's a great question. The simplest way to accomplish this is to create the view model that you don't want to constantly recreate in the UpdateCurrentViewModelCommand's constructor, store it in a private field on the UpdateCurrentViewModelCommand, and then just use the view model that is in the field whenever you switch views. As a result, you will have the same view model throughout your application because you will only create it in the constructor, and then reuse the field that you assign the view model to. For an actual example, I believe in episode 10 I create a view model (the BuyViewModel) that maintains it's state whenever you switch views. It might be confusing to jump to episode 10 without watching the previous episodes first because the Navigator architecture did change after adding dependency injection in episode 9. Hopefully this helps a little bit. Let me know if you have any other questions :)
@pandinor3358
@pandinor3358 4 жыл бұрын
@@SingletonSean Thank you. I will give it try and come back to you !
@pandinor3358
@pandinor3358 4 жыл бұрын
I think I need your help again. The actual UpdateViewCommand constructor in your application looks like this: private MainViewModel viewModel; public UpdateViewCommand(MainViewModel viewModel) { this.viewModel = viewModel; } How would you implement to create it through the constructor and store it in a field ? Just a little more advice would do the job. :o) Thank you, I really appreciate that.
@SingletonSean
@SingletonSean 4 жыл бұрын
Oh we talking actual code now?! I like talking code. Take a look at this branch I just created for you as a demonstration :) github.com/SingletonSean/SimpleTrader/blob/help/pandinor/viewmodel-state/SimpleTrader/SimpleTrader.WPF/Commands/UpdateCurrentViewModelCommand.cs Definitely let me know if you have any more issues/questions.
@pandinor3358
@pandinor3358 4 жыл бұрын
@@SingletonSean I followed your video on full stack mvvm navigation a few times and implemented your given code but unfortunately it doesn't work. The 2 textboxes on my viewmodel always appear with no text after switching between the views. Any further help ? Thank you again. ;o)
@UnknownMoses
@UnknownMoses Жыл бұрын
I'd like to see if you use the fluent api or attributes for defining max lengths of fields like varchar or nvarchar. Also I feel like the DomainObject couples the to class libraries together.
@SingletonSean
@SingletonSean Жыл бұрын
Ah yes, I typically use attributes for validation. Either approach (fluent API or attributes) is acceptable in my opinion. I agree with your stance on DomainObject. It's kind of a pointless abstraction anyways since I don't foresee anything else in the future that I'd need all domain objects to inherit. I probably wouldn't use it in a project nowadays unless I actually needed it for some odd reason, haha.
@anitasure3620
@anitasure3620 4 жыл бұрын
Hey, Thank you so much for the video. This is a great tutorial. I am also writing the code meanwhile and implemented everything as in the video but at 28.56 I am not getting anything in the Content Presenter when i click on radio buttons. I also implemented INotifyPropertyChanged event. Can you please guide me what can go wrong.
@SingletonSean
@SingletonSean 4 жыл бұрын
Hey Anita, thanks! Are you getting anything in your output logs, such as binding errors? Also, have you tried setting breakpoints/debugging to make sure your command is executing and your current view model is being set?
@anitasure3620
@anitasure3620 4 жыл бұрын
@@SingletonSean Hey. Thank you for being so responsive :) Yeah.. I'm not getting anything in the output unless this "The thread 0x5144 has exited with code 0 (0x0)". And also whenever i click on the radio buttons, CurrentViewModel is set. And would like to inform that i am applying your tutorial to an UWP application as i have a requirement on that :) So in support of UWP, instead of Binding NavigationBar DataContext in MainPage, i have bind it in the NavigationBar.xaml.cs page as xaml doent identify binding. And used x:bind whereever applicable. But still i cannot see the Home and Portfolio types in the ContentPresenter. Really not finding the issue! Thank you :)
@SingletonSean
@SingletonSean 4 жыл бұрын
Hmm I haven't touched UWP so I'm not sure how helpful I can be. From your comment and what I've read online, it seems UWP MVVM binding is pretty different from WPF. I might be able to help with source code posted. Also, are you using the same Navigator instance throughout your application (not "new"ing up more than one)?
@maximzavalievsky317
@maximzavalievsky317 4 жыл бұрын
@@SingletonSean Thank you for your video. It's very helpfull for me. However I can't biding NaviBar with UpdateCurrentViewModelCommand. I've tried debugging and I see that command isn't executing. How I can check? I sow video several times but this is still blocking point for me. I have no idea what is wrong.
@maximzavalievsky317
@maximzavalievsky317 4 жыл бұрын
me stupied! It was error 40, I had't public properties for datacontext binding!
@ragnarok7976
@ragnarok7976 Ай бұрын
You don't need to run the project you just have to build it. That will also add your custom control to the toolbox if you prefer to just drag and drop it on your window from there.
@tpops2697
@tpops2697 4 жыл бұрын
Followed this step by step with my project, except i was using regular buttons, which were on the left side in a column rather than the top. I can't seem to get where you got at the end of the video.
@SingletonSean
@SingletonSean 4 жыл бұрын
Hello T Pops, have you compared your project to the source code in the description?
@tpops2697
@tpops2697 4 жыл бұрын
@@SingletonSean Hey! I got it working but i found myself running into other problems today. I have a user control for my CustomersView that allow the user to enter customer information to add a new customer and below it i have a datagrid to show this data. It's connnected to a MySql database. The problem is i dont know where to start to implement the CRUD functions.
@SuperAndrea000000
@SuperAndrea000000 4 жыл бұрын
Nice tutorial. I'm following the series because it's very interesting and helps me a lot. I have a question. How can I change the current view programmatically (by code instead of using the radiobuttons)? I tried to inject the MainViewModel in the view model that needs to change the page, but I get a circular dependency exception and I don't think this is the best way of doing it. So I hope that you can give me an advice. Thanks.
@SingletonSean
@SingletonSean 4 жыл бұрын
Hello SuperAndrea, have you tried injecting the INavigator in the view model that needs to change the page? Then you can call UpdateCurrentViewModelCommand with the view type that you want to switch to, or even just straight up change the CurrentViewModel property if you're feeling dangerous.
@SuperAndrea000000
@SuperAndrea000000 4 жыл бұрын
@@SingletonSean Thank you for your quick answer. As you suggested, I tried injecting the INavigator into the view model that needs to change the page, but I get another circular dependency exception. I'll try to explain better what my problem is... I made a LoginViewModel with a LoginView to log the user in. I'd like to change the view to a specific page once the user has successfully logged in. The LoginViewModel (that needs the INavigator) is created by a LoginViewModelFactory following what you explained in one of your tutorials of this series). These are the components that the exception says are involved in the circular dependency: MainViewModel -> INavigator(Navigator) -> IRootMyProjectViewModelFactory(RootMyProjectViewModelFactory) -> IMyProjectViewModelFactory(LoginViewModelFactory) -> INavigator
@SingletonSean
@SingletonSean 4 жыл бұрын
Awesome discovery SuperAndrea. It's a strange edge case because our Navigator creates view models, but then some view models might also want to use the navigator. I did some research and found many people facing a similar problem, but actually couldn't find a clean solution. Luckily, I was able to come up with my own! We will definitely be implementing this in a video very soon for the login/register redirecting. Here's a demo I put together: github.com/SingletonSean/SimpleTrader/commit/e0964da2382cc2030aa303e3c75411fd945da270 I'll summarize what's going on in the commit above as best as I can: 1. I replicate your situation as best as I can by creating a BuyViewModelFactory and setting up the BuyViewModel so that after buying a stock, the user gets navigated to the Home page. The BuyViewModel now requires the Navigator in the constructor. 2. I create a special interface called an INavigationSimpleTraderViewModelFactory. The factory method on this interface takes in an INavigator. The BuyViewModelFactory implements this interface. Now, when the BuyViewModelFactory needs to create a BuyViewModel, the Navigator is provided in the function argument rather than in the constructor argument. 3. Overall, this solves the edge case and is practical because we have a reference to the Navigator whenever we need to create view models in the UpdateCurrentViewModelCommand.
@SuperAndrea000000
@SuperAndrea000000 4 жыл бұрын
@@SingletonSean Wow thank you for the smart solution in so little time. I tried your solution and it works perfectly. I'm looking forward to seeing the next video. I hope you'll keep up with this great work!
@SingletonSean
@SingletonSean 4 жыл бұрын
No problem, thanks for pointing this out SuperAndrea! Glad you were able to get it working too
@mrrob1454
@mrrob1454 2 жыл бұрын
At 2:48 I am getting two main windows opening. Is there something I am missing?
@SingletonSean
@SingletonSean 2 жыл бұрын
Hi Mr Rob, be sure to remove the "StartupUri" property in the App.xaml
@mrrob1454
@mrrob1454 2 жыл бұрын
@@SingletonSean Wow, you even said so in the video. You are of course The Man. Thanks!
@VinuP2023
@VinuP2023 4 жыл бұрын
Hi are you still going to continue this series 🙏😊?
@SingletonSean
@SingletonSean 4 жыл бұрын
Yep Vinay! This is my favorite series to work on at the moment. Still have a lot more to do too!
@eduhza
@eduhza 4 жыл бұрын
Hi @SingletonSean, I'm new to WPF .NET CORE and MVVM but I'm being able to understand everything until here. I have some concerns about this different type of framework. In Windows.Forms (.net framework), I used to have everything running on the code behind. I have an application that receives data from a SerialPort at 28bytes per milisecond, I'll call this 1sample/ms. In that application, I have multiple views in which one of them I use to configure the connection with the COM port. The LiveGraphView shows the data in real time, that I update every 25ms. The way it is today: On SettingsView, I configure the COM settings than I make a connection with MySerial.Open and create a DataReceived event (MySerial.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);). At this time the connection is made and I can switch to LiveGraphView and start seeing the data on the graph. But, in WPF .Core with MVVM when I change the view I change the viewModel consequently I cannot acess MySerial connection and get the data and when I come back to the SettingsView, it initializes a new SettingsViewModel so my last serial connection is "lost". Another example is on the LiveGraphView, suppose I'm receiving data and I already have 10000 samples on the graph (on an observableCollection), if I change the view and come back to LiveGraphView, I initiate a new LiveGraphViewModel and I lose it all. How can I mannage that? It seems that the Serial must be handled not inside a viewModel but on its on Model or service.... Please, any direction you point might be very helpful. Thank you.
@SingletonSean
@SingletonSean 4 жыл бұрын
Hey Eduardo, I understand your issue. There are two approaches you could take. The first approach would be re-using the same SettingsViewModel instance so that your data is not lost. The second approach would be handling your serial data outside of the view model, as you suggested. This is known as a "store". The store holds shared application state, and then the view models use the store to grab the shared data. This is inspired by the "mediator" design pattern. I demonstrate this later in the series, specifically in these files: AssetStore (shared data) github.com/SingletonSean/SimpleTrader/blob/master/SimpleTrader/SimpleTrader.WPF/State/Assets/AssetStore.cs AssetSummaryViewModel (uses AssetStore for data) github.com/SingletonSean/SimpleTrader/blob/master/SimpleTrader/SimpleTrader.WPF/ViewModels/AssetSummaryViewModel.cs
@eduhza
@eduhza 4 жыл бұрын
@@SingletonSean Thats true. The first approach I could change only the view and keep the viewModel... I'll try that. But I'll also take a look into the AssetStore, I think handling the serial data outside of the viewModel shall be a good idea. Thank you, Keep up your videos, you're helping a lot of ppl
@joongki8023
@joongki8023 2 жыл бұрын
@SingletonSean
@SingletonSean 2 жыл бұрын
Yes! No one ever uses the emojis, so thank you hahaha
@feitan8745
@feitan8745 4 жыл бұрын
Any tips on Caliburn?
@SingletonSean
@SingletonSean 4 жыл бұрын
I actually haven't touched Caliburn or any other WPF MVVM framework. I've always felt comfortable rolling my own style of MVVM. I'm confident that my approach to MVVM architecture is very simple, clean, and flexible, but then again I've never compared my style to Caliburn, Prism, etc.
@feitan8745
@feitan8745 4 жыл бұрын
@@SingletonSean Understood, nice series btw.
@markmulder4887
@markmulder4887 4 жыл бұрын
@@SingletonSean Doesnt it take alot of time to set this up on every WPF MVVM project?
@SingletonSean
@SingletonSean 4 жыл бұрын
@@markmulder4887 It does! In professional settings I have been in, we typically have a common library, but I have yet to create one for myself. Perhaps I will publish one later in this series.
@pikejuan
@pikejuan 4 жыл бұрын
that was so weird. as i clicked pause to go attend to something, *TIMEOUT* appeared on the screen. Thought it was a youtube feature.
@SingletonSean
@SingletonSean 4 жыл бұрын
Haha, perfect timing Juan!
@buddysnackit1758
@buddysnackit1758 2 жыл бұрын
Hey Where is episode 1 and 2.....add them as references....always do that or people will find something in progress and not be able to find the trails start. They'll find another trail and take that.
@SuperCorde
@SuperCorde 3 жыл бұрын
e
2 жыл бұрын
Couldn't the font size be reduced? Fucking not to see anything!
@SingletonSean
@SingletonSean 2 жыл бұрын
Hi Szederkényi, the font size is already very small in this video, so I don't think I should reduce it further 😞 instead, you could check out my newer series here: WPF MVVM Tutorial kzbin.info/aero/PLA8ZIAm2I03hS41Fy4vFpRw8AdYNBXmNm
@Spawny06
@Spawny06 2 жыл бұрын
I seem to be getting "No DataContext found for Binding 'Navigator'" in the MainWindow.xaml and "No DataContext found for Binding 'UpdateCurrentViewModelCommand'" in NavigationBar.xaml, any ideas what I've missed? Google hasn't helped and the code I have matches what is in the video.
@Spawny06
@Spawny06 2 жыл бұрын
Figured it out, it seems to work where the binding is {Binding UpdateCurrentViewModel} and not {Binding UpdateCurrentViewModelCommand}.
@purple66666
@purple66666 2 жыл бұрын
@@Spawny06 can you elaborate ? I 've run into the same problem as you
@bruno.theoret
@bruno.theoret Жыл бұрын
I am having the same issue right now... can anyone help please? - BTW, Thanks to Sean @SingletonSean, great tutorial, if not the best on WPF / EF / MVVM !!! :-)
@bruno.theoret
@bruno.theoret Жыл бұрын
I see no reference for 'public ICommand UpdateCurrentViewModelCommand => new UpdateCurrentViewModelCommand(this);' in State/Navigators/Navigator.cs, should have one...
World’s Largest Jello Pool
01:00
Mark Rober
Рет қаралды 110 МЛН
Они так быстро убрались!
01:00
Аришнев
Рет қаралды 2,3 МЛН
Jumping off balcony pulls her tooth! 🫣🦷
01:00
Justin Flom
Рет қаралды 28 МЛН
1,000 Diamonds! (Funny Minecraft Animation) #shorts #cartoon
00:31
toonz CRAFT
Рет қаралды 40 МЛН
WPF in C# with MVVM using Caliburn Micro
1:23:30
IAmTimCorey
Рет қаралды 362 М.
Dropdown - WPF UI COMPONENT WORKSHOP
14:43
SingletonSean
Рет қаралды 11 М.
How much does the Windows Community MVVM Toolkit REALLY help us?
7:02
Creating a Card Control - FULL STACK WPF (.NET CORE) MVVM #6
26:13
SingletonSean
Рет қаралды 15 М.
WPF Controls with MVVM: DataGrid
24:59
IAmTimCorey
Рет қаралды 172 М.
Models - WPF MVVM TUTORIAL #1
15:21
SingletonSean
Рет қаралды 199 М.
C#/WPF - Learn MVVM with the .NET Community Toolkit
1:46:13
Kevin Bost
Рет қаралды 51 М.
Nokia 3310 top
0:20
YT 𝒯𝒾𝓂𝓉𝒾𝓀
Рет қаралды 4,2 МЛН
КРАХ WINDOWS 19 ИЮЛЯ 2024 | ОБЪЯСНЯЕМ
10:04
Это - iPhone 16!
16:29
Rozetked
Рет қаралды 419 М.