Switching Between Multiple Views in MVVM - EASY WPF (.NET CORE)

Поделиться
HTML-код
  • Опубликовано: 13 дек 2024

Комментарии • 174

  • @SingletonSean
    @SingletonSean  3 года назад +15

    I strongly recommend checking out my series on navigation. Not only is the video quality much better, but the approach I use in that series is better-suited for larger applications, and I also cover other navigation scenarios.
    Link: ruclips.net/p/PLA8ZIAm2I03ggP55JbLOrXl6puKw4rEb2

  • @tatenda230788
    @tatenda230788 4 года назад +16

    This is a master piece code, explained in the most simplest form ....Thanks a lot from Zimbabwe

    • @SingletonSean
      @SingletonSean  4 года назад +2

      Thanks for watching Tatenda, glad you enjoyed!

  • @Psycho8Everything
    @Psycho8Everything 3 года назад +6

    This is a great resource on MVVM. At first I was using frames to attempt switching views but this is much simpler as well as trying to use pages instead of only UserControls, cheers for the tutorial. Saved me at least a week or so figuring this out!

  • @abdelhalimfellague_chebra9338
    @abdelhalimfellague_chebra9338 4 года назад +7

    well, this is the best video explaining navigation using MVVM so far, easy and simple, thank you verry much sir, you should keep doing this, nice work

    • @SingletonSean
      @SingletonSean  4 года назад +1

      Thank you abdelhalim, glad you enjoyed!

  • @mbjuggernaut
    @mbjuggernaut 2 года назад +2

    Thank you, highly helpful video (once I got that views here are usercontrols, not pages). Very understandable, very pleasant manner of explaining.

  • @StepanUa7
    @StepanUa7 4 года назад

    this is now all tutorials should be done, great work dude

  • @oualidberrim5218
    @oualidberrim5218 2 года назад

    You are amazing.. This is the best informative series of videos on RUclips.

    • @SingletonSean
      @SingletonSean  2 года назад

      Thanks Oualid, that means a lot! I'm glad these vids are helpful

  • @Saleca
    @Saleca 4 года назад +4

    Notice that you need to Add UserControl(WPF) for the Home and Account Views. I was struggling with that since I created Page(WPF)
    But great Tutorial very helpful, thanks.

  • @lucckyboy713
    @lucckyboy713 4 года назад +1

    Thank you so much. Your video makes it very clear how MVVM works. Thanks again. Hi from Belarus.
    10 / 10.

    • @SingletonSean
      @SingletonSean  4 года назад +1

      No problem Виктор, I'm glad you were able to solve your issues with the namespace. Trying a rebuild was a good idea. I'll suggest that next time someone has namespace issues, thanks!

  • @omerbilalcan
    @omerbilalcan Год назад +1

    Dear colleague,
    I developed to now web applications. But I didn't have any idea and it was different to understand before your tutorials. Now I am writing your codes line to line and trying to understand every points.
    Thank you so much about these resources.

  • @mehdizeynalov1062
    @mehdizeynalov1062 3 года назад

    Excellent tutorial - i have watched videos of tim corey - you can expect 20 minutes of this video more valuable than 20 hours of tim's.

    • @SingletonSean
      @SingletonSean  3 года назад

      Thanks Mehdi! I do prefer to keep my content short and concise. Tim's content is great too!

    • @mehdizeynalov1062
      @mehdizeynalov1062 3 года назад

      @@SingletonSean Thank you by no means I didn't want to tell bad about Tim, and should spent 20 years before I can do so... on the other hand, your videos are really great. just the thing i wanted to mention is as always popular doesn't mean good... I just found your videos totally by chance... On the other hand wish your videos to gain deserver popularity soon...

  • @ElCidPhysics90
    @ElCidPhysics90 3 года назад

    Your channel is way underrated.

  • @_SkyDancer
    @_SkyDancer 3 года назад +1

    7:14 So you always create new objects on command execution, I gues it is better to check if model is null then create one and store or smth like this, or I'm wrong?

  • @DatMight
    @DatMight 3 года назад +2

    Hello, how would you go about implementing this and then giving the ability to change the view depending on clicking/mousedown an element inside the ContentControl?

  • @theblackbaron4119
    @theblackbaron4119 2 года назад +1

    Thank you, that helped a lot. I did it a bit different with a switch case and even more strict separations/ abstractions and it worked :)

  • @shvideo1
    @shvideo1 4 месяца назад

    Excellent video. Thank you for sharing this very important concept.

  • @Saleca
    @Saleca 4 года назад +1

    @SingletonSean if I want instead of the main page button use a link inside the Home what do I need to do ?
    at the moment I have both and mainpage btn works but on the link says on console that cant find the file

    • @Saleca
      @Saleca 4 года назад

      I found the answer have to look for ancestors

  • @noahyannis2465
    @noahyannis2465 2 года назад +1

    But if the DataContext is set to the MainViewModel, how do I let my views access my other view models? Because otherwise, it seems I have to cramp everything into one MainViewModel.

  • @orlandoreyes884
    @orlandoreyes884 3 года назад

    Excellent!! This what I have been trying to do. Thank you.

  • @ryanrobbins4391
    @ryanrobbins4391 4 года назад +1

    saved my life. thanks for this awesome video!

  • @tpops2697
    @tpops2697 4 года назад +2

    What if i wanted to open another view within a view? For instance, on my dashboard I have a customers tab. I click that and im taken to a view where the datagrid of customers is shown. But i want to have a button on that page that displays a new view for me to add a customer.

    • @SingletonSean
      @SingletonSean  4 года назад +1

      Hey T Pops, that's a great question. It seems like your application has some pretty advanced navigation. For advanced navigation in WPF, I would recommend wrapping your "SelectedViewModel" in a class, such as "Navigator". Then, I would bind your ContentControl on the MainWindow to the Navigator.SelectedViewModel.
      Now that your SelectedViewModel is in it's own class (Navigator), you could pass your Navigator through the constructor of your other view models (such as your CustomerViewModel). Then, in your CustomerViewModel, you could use the Navigator and change the SelectedViewModel to whatever you want (such as NewCustomerViewModel).
      In my Full Stack WPF MVVM series, I demonstrate wrapping the SelectedViewModel in it's own Navigator class. This video focused on simple navigation, so perhaps I will dedicate a video to advanced navigation and demonstrate what you are trying to accomplish. Thanks for the idea! I apologize if my written description didn't help, but keep an eye out for a video in the future.

    • @tpops2697
      @tpops2697 4 года назад

      SingletonSean Thank you!

    • @r.o.9322
      @r.o.9322 3 года назад

      @@SingletonSean Did you manage to upload that video? It would be helpful! Thank you:)

  • @recepcakir4866
    @recepcakir4866 2 года назад

    Great tutorial!!
    Just have a question about stackpanel, I've put the buttons at the top of the window and I want the loaded page data to be displayed right below the buttons, how can I accomplish this?

  • @sometexthere4169
    @sometexthere4169 4 года назад +1

    Hello! Thank you for what you doing! I have a question. As programmer i always hate to repeat similiar code. For me "DataTemplate" block is excess. Is any opportunity to bind view and viewModel automatically? Like if i have HomeViewModel - so i need just HomeView. Thats it. Any suggestions?

  • @tungtran5305
    @tungtran5305 2 года назад

    At 3:50, i have no DataContext found for SelectedViewModel, can anyone help me w this? Much apperciate.

  • @parko1965
    @parko1965 4 года назад

    @SingletonSean just out of curiosity are you using the WPF Core templates for these tutorials?

  • @niklas6143
    @niklas6143 4 года назад +1

    I got the error "The event "UpdateViewCommand.CanExecuteChanged" is never used. I just copied your project and added/renamed the views and viewmodels. Can someone help?

  • @SoferPeOZN
    @SoferPeOZN 4 года назад +1

    I like it but it does not work when I try to change the SelectedViewModel within another view =(

  • @idnafu
    @idnafu 3 года назад +1

    Really nice tutorial and i was able to build the demo but now i have a strange issue. If i have a button in the MainWindow it works correctly.
    But if the button is on the Usercontrol that i loaded the ContentControl does not get updated even though the Updateviewcommand is fired and viewmodel.SelectedViewModel is set
    Any idea why that is?

  • @firewalker1606
    @firewalker1606 3 года назад

    Nice video! It is that i loocked for!

  • @linuslindstedt4065
    @linuslindstedt4065 2 года назад

    What WPF version are you doing?

  • @bigayysfromspace2804
    @bigayysfromspace2804 2 года назад

    I want buttons on my child views to switch contexts, but I wasn't able to get that to work. I tried putting the thing that stores the UpdateViewCommand function in the parent class and have the child view models inherit it, but that doesn't work. What should I do to achieve this objective?
    EDIT: when binding a function to a button, I have to bind the name that the viewmodel gave it, not the name of the class itself.

  • @bartomiejciurla8472
    @bartomiejciurla8472 7 месяцев назад

    Very usefull video! Thanks a lot!

  • @FuzzyDPozzy
    @FuzzyDPozzy 4 года назад

    what does the DataTemplate do?

  • @bigayysfromspace2804
    @bigayysfromspace2804 2 года назад

    Honestly a lifesaver. Problem is, build order stings a bit. If I wanted to add more views I need to change the csproj or remember to build before altering the App.xaml file.

  • @ElCidPhysics90
    @ElCidPhysics90 2 года назад

    Does MainViewModel need to be a viewmodel? Could it be just be just a c# class with a field or property that is the selectedViewModel?

    • @SingletonSean
      @SingletonSean  2 года назад +1

      Hi ElCidPhysics! The MainViewModel will indeed need to be a view model (implement INotifyPropertyChanged) since we bind to it from the view. Without implementing INotifyPropertyChanged, the view would not update when we switch views. There's also been discussion that binding to an object that doesn't implement INotifyPropertyChanged could cause memory leaks, but I've never seen it first-hand.

    • @ElCidPhysics90
      @ElCidPhysics90 2 года назад

      @@SingletonSean awesome. Thanks for the explanation. Learning WPF has been a struggle. I get WinForm, .Net, even Blazor to an extent. Bug fir whatever reason I’m struggling with WPF. Thanks for your videos.

    • @SingletonSean
      @SingletonSean  2 года назад +1

      No worries, it is certainly notorious for having a steeper learning curve 😅

  • @mr.paanaa3765
    @mr.paanaa3765 3 года назад

    thank you, sir. simple and powerful code

  • @M4RKU5H
    @M4RKU5H 3 года назад

    thanks, great starting point, but what if i only want to switch between the views and not having a new instance every time i switch?

  • @tpops2697
    @tpops2697 4 года назад

    I'm making an app that has a dashboard as the home screen, I want that to show at startup, so should I even have a dashboard view and just design that on the mainwindow?

  • @rohitgalgali5512
    @rohitgalgali5512 3 года назад

    Thank you very much for the video! :)

  • @sajadmalik9097
    @sajadmalik9097 4 года назад

    how am i going to put material design theme resources and data templates together ....i get errror

  • @seemovielove3597
    @seemovielove3597 4 года назад +2

    I barely see your screen. could you post some source code? thanks

  • @crazydreamer2324
    @crazydreamer2324 4 года назад

    Hello I tried in my mvvm project..but command is not getting fired from mainwindow though I given proper command and it's parameter...even debugger is not coming when I click home or account

  • @maikborchardt5692
    @maikborchardt5692 4 года назад

    love your work! thanks for your effort.

  • @shahjahan12003
    @shahjahan12003 4 года назад

    Awesome tutorial!

  • @ijazalishah1908
    @ijazalishah1908 4 года назад +1

    Hi, I found the following error,
    System.Windows.Markup.XamlParseException: 'Window must be the root of the tree. Cannot add Window as a child of Visual.'

    • @andreisirbu3012
      @andreisirbu3012 4 года назад +1

      Same ...

    • @crtvben3714
      @crtvben3714 4 года назад +2

      Your views have to be of type "User Control", not "Window"!

  • @Speede04
    @Speede04 2 года назад

    What if my viewmodels already inherit from another class?/ I can not implement BaseViewModel to them :(

  • @ritamgiri5872
    @ritamgiri5872 2 года назад

    Hi @SingletonSean
    I just started learning WPF. I was working on a personal project. I want to use two commands in a SIngle ViewModel. Can you suggest me how I do that or refer me a video?

    • @SingletonSean
      @SingletonSean  2 года назад +1

      Yes Ritam! I discuss this topic in this video (at around the 7:05 mark): ruclips.net/video/bYPU8X8f2xU/видео.html

    • @ritamgiri5872
      @ritamgiri5872 2 года назад

      Thank you very much.

  • @rcs368
    @rcs368 4 года назад +3

    I like what you are doing here, any chance you could zoom in a little, or increase your font size in the editor for video purpose?

    • @SingletonSean
      @SingletonSean  4 года назад +1

      Thanks rcs368, I had another viewer suggest I increase the font size as well. If you look at my recent videos, they should have larger fonts, but let me know if the font size still is too small. I apologize for the small fonts on my older videos, I was a rookie lol.

    • @rcs368
      @rcs368 4 года назад +1

      @@SingletonSean I noticed on the next video I watched the font size was MUCH better. Thanks

    • @SingletonSean
      @SingletonSean  4 года назад +1

      Great! Thanks for the feedback.

  • @CarloJS
    @CarloJS 4 года назад

    hi do you have a github repo for this demo?

  • @pepeArz
    @pepeArz 3 года назад

    I know this is easy, but, how can I show one of this pages at the start of the application?

  • @_samirdahal
    @_samirdahal 4 года назад

    Okay so I am having a funny issue now. It used to work from App.xaml . Now when I bind to a new instance to the 's Content property I can't open the respective views. But when I add

  • @robertenglund3578
    @robertenglund3578 4 года назад

    Gives an error in the App.xaml file at saying - " The HomeViewModel does not exist in the namespace " clr-namespace:MMVMTesting2.ViewModels ".
    Any idea if what would cause this Error?

    • @robertenglund3578
      @robertenglund3578 4 года назад

      Nevermind, just needed to Build the application and the issue was resolved

    • @SingletonSean
      @SingletonSean  4 года назад

      Awesome Robert, way to persevere through your issues!

  • @majordan9747
    @majordan9747 4 года назад

    Hello, thanks for your video.
    What does the DataTemplate have to be built?

    • @SingletonSean
      @SingletonSean  4 года назад +1

      Hey Ma Jordan, thanks for watching! The DataTemplate tells WPF what to display for a certain type. For example, at 2:27 we create a ContentControl and set the Content property to our SelectedViewModel. At 4:05, I use a DateTemplate to basically tell WPF that HomeViewModels should be displayed as HomeViews. As a result, when the type of the Content property on the ContentControl is a HomeViewModel, the ContentControl will display a HomeView.

  • @rain2223
    @rain2223 4 года назад

    Hey, when I press a button nothing happens, and this is in my output:
    System.Windows.Data Error: 40 : BindingExpression path error: 'UpdateViewCommand' property not found on 'object' ''Login1ViewModel' (HashCode=31450711)'. BindingExpression:Path=UpdateViewCommand; DataItem='Login1ViewModel' (HashCode=31450711); target element is 'Button' (Name=''); target property is 'Command' (type 'ICommand')
    How can I fix this? Basically, I did the same thing as you, except that my button is not in MainWindow, but in Login1View instead.

    • @SingletonSean
      @SingletonSean  4 года назад +1

      Hi Rain, the issue is that your DataContext for your button is the Login1ViewModel. Therefore, your UpdateViewCommand will need to be on your Login1ViewModel as well. Otherwise, your button will be unable to find the command.
      It seems that you are attempting to navigate to a different view from within another view, correct? I have many people asking about this, so perhaps I will make a video on solving this navigation case.

    • @rain2223
      @rain2223 4 года назад

      @@SingletonSean Yes, that is what I'm trying to do. A video would be great :)

    • @rain2223
      @rain2223 4 года назад

      @@SingletonSean Still haven't managed to fix it :( Do you perhaps have an example of this somewhere? I'm getting some weird errors and I don't even know where to begin debugging it.

    • @noahyannis2465
      @noahyannis2465 2 года назад

      @@rain2223 could you fix it now?

  • @limbique
    @limbique 3 года назад

    Does it mean that for each new type of viewmodel, you need to alter the app.xaml?

    • @SingletonSean
      @SingletonSean  3 года назад

      That is true Limbique. You would also extract all the viewmodel-to-view mappings to their own ResourceDictionary so that they are easier to find. Then you'd just need to import the ResourceDictionary into the App.xaml. I usually do this whenever I have a ton of views/view models.

  • @mrcoolandroid
    @mrcoolandroid 2 года назад

    Hello, i find your videos really helpful but i have a question, how would I go if i want to change the view from another ViewModel?

  • @tacci2568
    @tacci2568 3 года назад

    nameof() doesnt work for me working with visuals stuido 2013, same goes for ProperyChange?.Invoke

    • @SingletonSean
      @SingletonSean  3 года назад

      That's correct Tacci, those are new VS features. I used to always have to work in VS 2013 in legacy projects :(
      If you're unsure, the alternative to nameof() is simply the name of the property as a string. The alternative to PropertyChanged?.Invoke is to null check PropertyChanged, and then call PropertyChanged like a method. Thanks for watching!

    • @tacci2568
      @tacci2568 3 года назад

      @@SingletonSean ye i already found out, but my view is still not changing, even tho my button is working , perhaps its because i binded the SelectedViewmodel as ContentControl on the main window, but i cant bind it as Content Control on my user COntrol

  • @iftaker1
    @iftaker1 4 года назад +1

    Thanks for the video, very simple and straightforward to understand. However I was wondering why didn't you use pages instead of user control for views? Is there any special considerations while using pages instead of user control?

    • @SingletonSean
      @SingletonSean  3 года назад +5

      Hey Iftaker, that's a great question. Pages are most beneficial along with NavigationWindows. Since I typically just use a plain Window, I almost always use UserControls.
      EDIT: In fact, here's a good SO comment that talks about Window vs. Page vs. UserControl: stackoverflow.com/a/20292416

  • @leek2436
    @leek2436 2 года назад

    How can i display a usercontrol by clicking a button in another usercontrol ?

  • @rafaspimenta
    @rafaspimenta 4 года назад

    Good teacher! bty, do you use Caliburn in bigger apps?

    • @SingletonSean
      @SingletonSean  4 года назад

      Thanks Rafael! Many people ask about my experiences with WPF frameworks. I haven't used Caliburn before on a large app, but I have played around with it and browsed through the docs. I'm not a big fan of the framework's conventions, and I also noticed the project is no longer under maintenance. I feel more comfortable using WPF without a framework. I've read many varying opinions on WPF frameworks, so I don't think there's any right or wrong option.

  • @jwvisions
    @jwvisions 4 года назад

    How are you doing this without a page in a frame? I followed word for word, even paused to make sure our code was the same, but it keeps yelling at me that a page must be part of a frame when I try to run.

    • @jwvisions
      @jwvisions 4 года назад +1

      Never mind. I believe I discovered they are UserControls, not pages. Good tutorial to show the MVVM framework.

    • @SingletonSean
      @SingletonSean  4 года назад

      Beat me to it! That's correct, UserControls instead of Pages. Great job exploring and solving the problem on your own. Thanks for watching Jesse, glad the video helped.

  • @yasirali9190
    @yasirali9190 2 года назад

    I have a problem of data lost in views when i switch views then views can't hold data

  • @karajkot6735
    @karajkot6735 4 года назад

    Github link if possible.
    I think I am doing something wrong in views folder content

  • @AlexHuang226
    @AlexHuang226 3 года назад

    After I tried the code, I found every time when I clicked the button, it will create another instances. That means if I click 10 times Home or Account button, it will create 10 instances of Home view and Account view. Did I miss anything?

    • @SingletonSean
      @SingletonSean  3 года назад

      That is correct Alex! The garbage collector will cleanup the previous 9 instances of views/view models, so no need to worry about memory leaks.

    • @AlexHuang226
      @AlexHuang226 3 года назад

      @@SingletonSean Thanks for your reply. :)

  • @M7829-f7q
    @M7829-f7q Год назад

    Great tutorial. It's only 50% of my problem. How do you pass data objects from MainViewModel to the new view ?

  • @Danger418
    @Danger418 4 года назад

    Good tutorial, thanks!

    • @SingletonSean
      @SingletonSean  4 года назад

      Thanks Danger418, glad you enjoyed it!

  • @solvedplus858
    @solvedplus858 3 года назад

    this is great
    many thanks
    can you show us how to use enum in commandparameters instead of normal text
    how to open new window and collect data from it using MVVM
    thanks in advance

  • @douglasbates389
    @douglasbates389 4 года назад

    Sorry did not leave a contact
    Hello, I found your video very useful. How could I change the button(s) and put a treeview control in place to change the views. Also in the TreeView I would like to have a just one known Parent Node (by Name) have a contextmenu that adds a child. Then in the Child Nodes of this particular Parent Node have a different ContextMenu that has two options Rename and Delete. One thing to note with the known Parent Node is that the Child Node(s) all use the same view and only the data changes. The structure would be:-
    +Root
    +Parent1
    Child1 {view UserControl1}
    Child2 {view UserControl2}
    +Parent2
    Child1 {view UserControl3}
    Child2 {view UserControl4}
    +ParentX {ContextMenu(P) - Add Child}
    ChildX1 {ContextMenu(C) - Rename Child, Delete Child} {view UserControlX}
    ChildX2 {ContextMenu(C) - Rename Child, Delete Child} {view UserControlX}
    ChildX3 {ContextMenu(C) - Rename Child, Delete Child} {view UserControlX}
    +Parent3
    Child1
    Child2
    Can you help me please or point me in the correct direction.
    Bates.JamesDouglas@gmail.com
    Show less

  • @notlegal99
    @notlegal99 3 года назад

    you are my god

  • @Dayzito
    @Dayzito 4 года назад

    Thanks for creating this tutorial =)
    Do you have an example sharing property among ViewModels, for instance,, ListView => DetailsView

    • @SingletonSean
      @SingletonSean  4 года назад

      Thanks for watching Day! Unfortunately, I don't have a specific video on this, but have this in the plans for a really awesome series. I think what you might be looking for is the concept of 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 think my best example is in my SimpleTrader application, specifically with these files:
      AssetStore (shared properties)
      github.com/SingletonSean/SimpleTrader/blob/master/SimpleTrader/SimpleTrader.WPF/State/Assets/AssetStore.cs
      AssetSummaryViewModel (uses AssetStore for shared properties)
      github.com/SingletonSean/SimpleTrader/blob/master/SimpleTrader/SimpleTrader.WPF/ViewModels/AssetSummaryViewModel.cs

  • @lucckyboy713
    @lucckyboy713 4 года назад

    Why
    write "The type views:HomeView was not found "?

    • @SingletonSean
      @SingletonSean  4 года назад

      Did you import the views namespace into your App.xaml? Is your HomeView in the namespace "views"? If you post a link to your code, I will be able to diagnose the issue.

    • @lucckyboy713
      @lucckyboy713 4 года назад

      @@SingletonSean Thank you ) I resolved it . Just re-build)

  • @knowledgesharer6983
    @knowledgesharer6983 2 года назад

    Anyone can tell me how command in Views knows about the ViewModel?

  • @Inzurrekto1
    @Inzurrekto1 4 года назад

    Thank you so much bro!

    • @SingletonSean
      @SingletonSean  4 года назад

      Thanks for watching Nicolás!

    • @Inzurrekto1
      @Inzurrekto1 4 года назад

      @@SingletonSean Hey, I have a question. How I can switch panels but with a single instance of each one?

    • @SingletonSean
      @SingletonSean  4 года назад

      Hey Nicolás, great question. I actually get that question a lot, so I ended up making a demo last time someone asked. Take a look at this:
      github.com/SingletonSean/SimpleTrader/commit/428c6de1c52e4973495dc8ab4837a839050c886c
      The main idea is that you store the view model in a field and set the SelectedViewModel to the view model in the field whenever you want to switch back to the view. Let me know if you have any issues :)

  • @fluffymaverick
    @fluffymaverick 2 года назад

    Bro I'm not yet done with the whole video but I know that this is exactly what I was looking for. This is the very basic that I need to continue your SimpleTrader playlist currently on part 10 but I need to go back to get the basic understood well.
    PS. The financialprep api for ticker price cannot be accessed anymore if you are not a premium member. I'm having a hard time how to catch up with your tutorial if some of the api endpoints cannot be accessed anymore.

    • @SingletonSean
      @SingletonSean  2 года назад

      Glad this is helpful Alvin! As for the SimpleTrader playlist, sadly there's not much we can do about the API being premium only now. However, I'd recommend checking out this tutorial! ruclips.net/p/PLA8ZIAm2I03hS41Fy4vFpRw8AdYNBXmNm
      It's much more concise and covers WPF features better imo.

    • @fluffymaverick
      @fluffymaverick 2 года назад

      ​@@SingletonSean Thank you for the recommendation. This would be a perfect time to spend my weekend watching and learning from this playlist you provided.
      So far you both Tim Corey and You are the real OG of C# for me not joking 😤

  • @crazydreamer2324
    @crazydreamer2324 4 года назад

    Please suggest @singleton sean

  • @shritishaw8617
    @shritishaw8617 4 года назад

    can you share the code

  • @XPWHACTL
    @XPWHACTL 4 года назад

    I've tried this method and I'm not getting anything showing where the view should be :/

    • @SingletonSean
      @SingletonSean  4 года назад

      Hello David, I will be able to solve your issue if you provide source code. However, are there any errors in the output window when debugging? Did you map your views to view models in your App.xaml? Is anything being displayed on the screen (such as the names of the view model classes)?

    • @XPWHACTL
      @XPWHACTL 4 года назад

      @@SingletonSean I've completely recreated the project practically ad verbatum and I see no errors and nothing displayed on the screen.

    • @SingletonSean
      @SingletonSean  4 года назад

      I would love to help, but I cannot give suggestions or feedback without seeing your current project.

    • @XPWHACTL
      @XPWHACTL 4 года назад

      @@SingletonSean www.sendspace.com/file/q3boey Here is the project. I would much appreciate it if you could take a look.

    • @CH-mk1dh
      @CH-mk1dh 4 года назад

      Hello,
      You have to to the following Things:
      - in our MainWindow.xaml.cs File you have to add "DataContext = new MainViewModel();" in your Constructor
      - your AView.xaml.cs and BView.xaml.cs Files are missing
      sorry for my bad English :)

  • @yanzhainie484
    @yanzhainie484 4 года назад

    Hello, your video is great help for me to learn wpf. Hope some mvvm framework videos,such as mvvmcross or prism. Thanks

    • @SingletonSean
      @SingletonSean  4 года назад

      Hey Yanzhai, glad the video helped. Personally, I have never felt the need for an MVVM framework as I feel WPF has good support for MVVM, but many people have requested I try out a framework. I always feel like I learn something useful from trying frameworks, so I might take a look.

    • @davidporterrealestate
      @davidporterrealestate 4 года назад

      @@SingletonSean Take a look at ReactiveUI

  • @tpops2697
    @tpops2697 4 года назад

    Let's say you wanted your home view to show at startup, how would that work?

    • @SingletonSean
      @SingletonSean  4 года назад

      Hey Tanner, have you tried simply executing the UpdateViewCommand from your MainViewModel constructor?

    • @tpops2697
      @tpops2697 4 года назад

      @@SingletonSean Yes. this (gyazo.com/6fa4296371a2323aad0425d9e5a602af) is my MainWindow at launch. When I start the app, I would like for the Dashboard View to be shown by default where the white space is. I have already set that area of the screen for the content control, I'm just wondering how to display this particular View by default without having to click the Button for it after startup. (highlight link and copy, clicking doesnt show image). Thanks for the help!

    • @SingletonSean
      @SingletonSean  4 года назад

      Does the UpdateViewCommand execute from your constructor? Have you tried walking through/debugging with breakpoints and seeing if the SelectedViewModel is being set?

    • @Saleca
      @Saleca 4 года назад

      @@tpops2697 try add back the "new HomeViewModel(); in the MainViewModel

  • @ВладимирКовяко
    @ВладимирКовяко 2 года назад

    nice thank you :)

  • @mekkelek8190
    @mekkelek8190 2 года назад

    It is a great tutorial but for me the previous View does not disappears on the button click it puts the new content on top of the other I'm sure I missed something but can't find what 😵‍💫

  • @TheSoulT
    @TheSoulT 3 года назад

    Nice Video, thank you.
    Can you explain how i can highlight the button of the active page? Would be very helpful.
    Thanks :)

  • @7oussemTube
    @7oussemTube 3 года назад

    I'm looking for tutorial like this for a while. I just want to ask you how can I build the same project using .Net Framework (Not .Net core)? and how to use MVVM inside my current project(I'm using .Net Framwork 4.6) ?...Thank you bro in advance.

  • @theway5258
    @theway5258 4 года назад

    Thanks. man!

  • @BloodyClash
    @BloodyClash 2 года назад

    Problem ist that this doesn't work in .Net Core for any reason (no problem in .Net Framework).
    Edit: It DOES work in .Net when you switch the core version from 6.0 to 5.0 (and then back to 6.0). Maybe it's one of the Visual Studio's hiccups

  • @yanchuntang7750
    @yanchuntang7750 2 года назад

    can you make screen bigger, the font size is too small to read. any way good video

  • @afterbunny257
    @afterbunny257 4 года назад

    public void OnPropertyChanged([CallerMemberName] string propertyName = null){ ... }
    can save your time typing the prop name

    • @SingletonSean
      @SingletonSean  4 года назад

      I like using CallerMemberName, but some projects I work in don't use it :( so I just always pass in the property name as a habit in case the project doesn't use CallerMemberName. Plus, I created a snippet that generates all the code for an OnPropertyChanged property, so it doesn't bug me much. For personal projects I should just use it though lol. Thanks for the suggestion Afterbunny!

  • @dsacppracticequestion1123
    @dsacppracticequestion1123 Год назад

    Please try to make the fonts little bigger, very hard to see the text.

    • @SingletonSean
      @SingletonSean  Год назад +1

      Hey DsaCpPractice, my videos have much better font size nowadays. This was actually my very first video!

  • @daniyalihsan4264
    @daniyalihsan4264 3 года назад

    Sir kindly make sure that you zoom in while delivering lecture rest is good.

    • @SingletonSean
      @SingletonSean  3 года назад +1

      This was my first video ever (as you can probably tell by the quality hahaha). My newer videos have much better quality. Thanks for watching, Daniyal!

  • @shantunusaha
    @shantunusaha 4 года назад +1

    It will be better if you share your source code also.

  • @lmao01
    @lmao01 3 года назад

    tyty

  • @kumarrishabh3587
    @kumarrishabh3587 3 года назад

    please increase the font size

    • @SingletonSean
      @SingletonSean  3 года назад

      Hey kumar, my newer videos have the increased font size. Check out this series if you want to see navigation videos with increased font size :) ruclips.net/p/PLA8ZIAm2I03ggP55JbLOrXl6puKw4rEb2

  • @downware2149
    @downware2149 2 года назад

    you should try to make videos when you are sober 😄

  • @mb-ql1gb
    @mb-ql1gb 4 года назад

    Very complicated and much code only for changing content.
    Why not making CunstomControls as Form and exchange them in DataContext on Mainform? That also needs no PropertyChanged for Mainform.

    • @SingletonSean
      @SingletonSean  4 года назад

      Hey mb, thanks for watching and glad to hear you enjoyed the video. This is WPF, so unfortunately I'm not sure what you mean by form. I also prefer keeping my navigation in the view model so I can navigate from inside a view model whenever I need to. However, I'm always interested in seeing other people's ideas in action, so it would be awesome if you linked to an implementation of your solution if possible.

    • @mb-ql1gb
      @mb-ql1gb 4 года назад

      @@SingletonSean This is what I hate about WPF, much code for less things.
      But I must excuse myself, watching it on 2 times speed was too fast. You did it right and in correct way. Maybe you can save the ICommand by using code-behind with that click-event. But as always there are hundreds ways to solve a problem.
      Also I never used a Property-Changed-Event for that, reassigning the data-context did an update by itself, if I remember right.
      With "Mainform" I ment MainWindow., you also still used a UserControl, so please excuse my mistake.
      But otherwise a very good tutorial and very good explained!
      I myself experimented with a more crazy way, I made every model-view static and let them handle his Window by itself. Exchanging data between different view is easy that way, but it takes a little bit of that separation between UI and Code, but for most applications a correct done MVVM is way to much work to implement, so I tried a way between.

    • @SingletonSean
      @SingletonSean  4 года назад

      Hey mb, thanks for the feedback, I love discussing solutions and those are good points. I agree, could save an ICommand implementation or even use the "RelayCommand" that everyone seems to love, but like you said hundreds of ways to solve a problem, hahaha. Anyways, you're definitely right that it does take a lot of code to do some things in WPF, and making that choice really depends on the scope of your project. Like you suggested, many simple projects probably don't need to spend time implementing a pure MVVM solution. I'm sure you're not the only one who thinks this takes too much code, so I would like to revisit my implementation and see if I could simplify the solution. I've explored a lot with navigation since I made this video.

  • @angelbarrantes3226
    @angelbarrantes3226 Год назад

    if this helps me, i will give an star on github 🙂

  • @basharfocke
    @basharfocke Год назад

    I am the like 1001

  • @MaikeLDave
    @MaikeLDave 3 года назад

    Easy xD

  • @ironside915
    @ironside915 4 года назад

    Terrible. I got lost within minutes even tho I tried super hard...

    • @SingletonSean
      @SingletonSean  4 года назад

      Hey Ironside, be sure to subscribe and check out my other videos for more help on getting started with WPF.