Great series, as just started following along, not sure if the Financial site changed, but needed to sign up and append the api key, just incase anyone else was having issues. Great stuff tho meaning to learn MVVM
Hey Dame, thank you for pointing this out! I'll have to make a quick video on setting up an API key. You win the prize for pinned comment though, hahaha.
I learn a lot from your videos, but I have a little trick for you and the other viewers too: if you add the following line to the declaration of your views/controls, you have support for type ahead also and this helps reduce the amount of "why is this not showing...oh I made a typo here" kind of errors. This also helps when renaming things since now these references can be found using e.g. Resharper d:DataContext="{d:DesignInstance Type=nav:Navigator, IsDesignTimeCreatable=False}"
Hi Sean, I've been meaning to follow this series for a long time now and finally got the time to chip away at it. Great work! It's very clearly presented. I've noticed the suffixes have changed for each market (Dow "^DJI", Nasdaq "^IXIC" and SP500 "%5EGSPC"). Also, i'm not sure you cover it in your video but WPF doesn't automatically render clear and sometimes we need to use the UseLayoutRounding="True" property on a UIElement.
one thing could be useful is to use display key struck . I am wondering how you navigate the snippet, since when I was pressing tab on "myVar" it switched from "_nasdaq" to "majorIndex" and I see your intellisense also suggested that but didn't change. at the moment I am pressing up then tab to avoid this but gets annoying sometimes I don't notice the change. and once again great work.
How did you learn WPF to this degree of proficiency? My mind is blown by how much you can do. I thought I was okay with WPF but I am learning so much from your videos.
Hey MS204, it's all about practice and exploring. It also takes some questioning, such as "Is there a better way to do this? Is this extendable and maintainable?". I can guarantee that the first WPF program I wrote is nothing like what I write nowadays, haha. Another thing that has helped a TON is exploring front end JavaScript frameworks, such as React and Vue. I've learned a lot of principles from JS frameworks that I've been able to apply to WPF. Plus it's much easier to find learning resources in the JS ecosystem compared to WPF (sadly).
Hi Sean. Usually you try to decouple the View and the code-behind implementation as much as possible. Here you make direct references to the ViewModel classes in the ConverterParameter of {Binding CurrentViewModel}. Would you think of a way to improve that?
I think you should have adapted the code to be able to have an undefined number of major index But other than that, thank you for your great videos. They really are the best I have found for the moment, and I searched a lot about wpf.
Hey Sean, Isn`t it better to write something like return value.GetType().FullName == parameter.ToString(); Instead of return value.ToString() == parameter.ToString(); In EqualValueToParameterConverter so that you will not bother whether or not the ToString Method is overridden?
Hi, sorry if it feels like I'm blowing up your comments, I just like to share ideas I've found, have dialogue, and/or ask questions as I go through your tutorials, I hope I don't ever come across as critical, because I'm not. For the part where we need to convert a property to a full property, I paused before seeing you created a cool snippet for that feature. Then I found that you can highlight the property, ctrl+. it, and 'convert to full property'. It created a streamlined version: private MajorIndex dowJones; public MajorIndex DowJones { get => dowJones; set => dowJones = value; } I then selected the dowJones field, CtrlR+R to add the _ to it with a rename, and took the Lamda arrow away from the set and replaced it with curly brackets, so it could hold 2 statements, resulting in private MajorIndex _dowJones; public MajorIndex DowJones { get => _dowJones; set { _dowJones = value; OnPropertyChanged(nameof(DowJones)); } } I found I like the one liner for the get and set (as long as it doesn't get more complicated down the road), but it wasn't break point friendly. I found I could just hit enter before 'OnPropertyChanged()' to set a temporary breakpoint if needed though, then could put it back to the one-liner. I just thought I'd share my thoughts a bit on how to shrink up the property. I think it would be neat to have a snippet for that type of format. :-)
Hey JC, that's not a bad idea. Those dang property changed properties do take up a lot of space, so it would be beneficial to make them one-liners. I usually don't need to place breakpoints in them anyways. I might edit my snippet, but in the meantime feel free to edit the downloadable one. It should be straight-forward to alter, just removing line breaks :)
@@SingletonSean *I found a way to streamline these properties even more. Instead of passing in the name using nameof(), you can just do this: *In your ViewModel base class, update the method to use [CallerMemberName] like this: protected virtual void OnPropertyChanged([CallerMemberName]string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } and use it like this: private string _symbol; public string Symbol { get => _symbol; set { _symbol = value; OnPropertyChanged(); } } *and for cases where you need to pass in a different name than the calling name, you can still do so, such as this: private double _stockPrice; public double StockPrice { get => _stockPrice; set { _stockPrice = value; OnPropertyChanged(); OnPropertyChanged(nameof(TotalPrice)); } } Just another way to do the same thing, lol, thought I'd share. :-)
Great video series so far. I am having a bit of an issue though. When I try to load up the view model by default when starting the application, I get a stack overflow error. My App.xaml.cs is loading the main window, setting the data context to my MainViewModel, and then the navigator takes over. The navigator is instantiated and set in the MainViewModel like you have done, and in the constructor of the MainViewModel I call Navigator.UpdateViewModelCommand.Execute(ViewType.Home); as you have. When I set a breakpoint though inside of the UpdateCurrentViewModelCommand switch statement, it hits correctly as a Home Type, but that creates another view model for MainViewModel and circles back to the constructor of the MainViewModel again, and loops until I get a stackoverflow error. As far as I can tell, I have it setup like you, so I don't fully understanding what is going on here. Any insight if others might have run into this issue would be much appreciated! Thank you so much!
NVM figured it out. I was trying to use the Main View Model as my home view model too still. I changed that to load the main view model first, and then set the Navigator to use the HomeViewModel instead and it loaded fine with circling back on itself over and over again. Thanks again for the great tutorials so far!
So far this is an awesome series. Well done. Thanks, Sean. Question: How would you handle the card display if you didn't know the number of majorindexes? Say it was a different object you were putting in the card but you weren't sure how many of them you had. How would you handle adding that to the display?
Hey ElCidPhysics, I have this issue quite frequently! The trick is to use an ItemsControl and define a custom ItemTemplate. I'm not sure I have an example of this, but I want to do a video on this. It's pretty much the equivalent of a doing a "for loop" in XAML.
Hey Gajaruban, that's a planned feature! To implement that, I plan to use a Timer that will ping our MajorIndexService and refresh the cards. It will be exciting.
Hey Sean, I´m following your tutorials and they are fantastic. I would like to ask you something. Are you currently using a MVVM framework for your projects? Cheers from México, Sergio Camacho
Hey Sergio, currently I am not using an MVVM framework. I feel comfortable just using vanilla WPF. However, many people have asked about frameworks, so I might have to check one out! Glad to hear you're enjoying the tutorials.
@@SingletonSean Thanks for the answer. That is great to hear. I think that the frameworks just complicate things and they are a little bit overwhelming to learn. The only nuget packages that I consider very useful is the ones called Fody and PropertyChanged.Fody. They take care of the full implementation of the properties in classes that implement the INotifyPropertyChanged.
Great series, as just started following along, not sure if the Financial site changed, but needed to sign up and append the api key, just incase anyone else was having issues.
Great stuff tho meaning to learn MVVM
Hey Dame, thank you for pointing this out! I'll have to make a quick video on setting up an API key. You win the prize for pinned comment though, hahaha.
This is a really , really good vid - its not "mid" as the youth would say round my way....
No doubt!!! A treasure for a learner! XAML is a deep sea for sure! While, at the same time you sure have proved to be an ideal Lifeguard!
Thanks SS!!!
Just want to say that I am glad that I checked out this tut. Excellent job. Thanks
I learn a lot from your videos, but I have a little trick for you and the other viewers too:
if you add the following line to the declaration of your views/controls, you have support for type ahead also and this helps reduce the amount of "why is this not showing...oh I made a typo here" kind of errors. This also helps when renaming things since now these references can be found using e.g. Resharper
d:DataContext="{d:DesignInstance Type=nav:Navigator, IsDesignTimeCreatable=False}"
"like"ing every video in this series as I go through
dude writes code, code works
i copy his code, code works, its magic!
Haha, that's a great sign ameer!
At 12:00 you right-align everything in the first row, with the effect that everything in the first _column_ becomes aligned. Wizardry...
Hi Sean, how would you go about adding cards on a view dynamically? Do you have any videos on that topic?
Hi Sean, I've been meaning to follow this series for a long time now and finally got the time to chip away at it. Great work! It's very clearly presented. I've noticed the suffixes have changed for each market (Dow "^DJI", Nasdaq "^IXIC" and SP500 "%5EGSPC"). Also, i'm not sure you cover it in your video but WPF doesn't automatically render clear and sometimes we need to use the UseLayoutRounding="True" property on a UIElement.
one thing could be useful is to use display key struck . I am wondering how you navigate the snippet, since when I was pressing tab on "myVar" it switched from "_nasdaq" to "majorIndex" and I see your intellisense also suggested that but didn't change. at the moment I am pressing up then tab to avoid this but gets annoying sometimes I don't notice the change. and once again great work.
How did you learn WPF to this degree of proficiency? My mind is blown by how much you can do. I thought I was okay with WPF but I am learning so much from your videos.
Hey MS204, it's all about practice and exploring. It also takes some questioning, such as "Is there a better way to do this? Is this extendable and maintainable?". I can guarantee that the first WPF program I wrote is nothing like what I write nowadays, haha. Another thing that has helped a TON is exploring front end JavaScript frameworks, such as React and Vue. I've learned a lot of principles from JS frameworks that I've been able to apply to WPF. Plus it's much easier to find learning resources in the JS ecosystem compared to WPF (sadly).
Hi Sean. Usually you try to decouple the View and the code-behind implementation as much as possible. Here you make direct references to the ViewModel classes in the ConverterParameter of {Binding CurrentViewModel}. Would you think of a way to improve that?
I think you should have adapted the code to be able to have an undefined number of major index
But other than that, thank you for your great videos. They really are the best I have found for the moment, and I searched a lot about wpf.
Hey Sean,
Isn`t it better to write something like
return value.GetType().FullName == parameter.ToString();
Instead of
return value.ToString() == parameter.ToString();
In EqualValueToParameterConverter so that you will not bother whether or not the ToString Method is overridden?
Hi, sorry if it feels like I'm blowing up your comments, I just like to share ideas I've found, have dialogue, and/or ask questions as I go through your tutorials, I hope I don't ever come across as critical, because I'm not. For the part where we need to convert a property to a full property, I paused before seeing you created a cool snippet for that feature. Then I found that you can highlight the property, ctrl+. it, and 'convert to full property'. It created a streamlined version:
private MajorIndex dowJones;
public MajorIndex DowJones { get => dowJones; set => dowJones = value; }
I then selected the dowJones field, CtrlR+R to add the _ to it with a rename, and took the Lamda arrow away from the set and replaced it with curly brackets, so it could hold 2 statements, resulting in
private MajorIndex _dowJones;
public MajorIndex DowJones { get => _dowJones; set { _dowJones = value; OnPropertyChanged(nameof(DowJones)); } }
I found I like the one liner for the get and set (as long as it doesn't get more complicated down the road), but it wasn't break point friendly.
I found I could just hit enter before 'OnPropertyChanged()' to set a temporary breakpoint if needed though, then could put it back to the one-liner.
I just thought I'd share my thoughts a bit on how to shrink up the property. I think it would be neat to have a snippet for that type of format. :-)
Hey JC, that's not a bad idea. Those dang property changed properties do take up a lot of space, so it would be beneficial to make them one-liners. I usually don't need to place breakpoints in them anyways. I might edit my snippet, but in the meantime feel free to edit the downloadable one. It should be straight-forward to alter, just removing line breaks :)
@@SingletonSean *I found a way to streamline these properties even more. Instead of passing in the name using nameof(), you can just do this:
*In your ViewModel base class, update the method to use [CallerMemberName] like this:
protected virtual void OnPropertyChanged([CallerMemberName]string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
and use it like this:
private string _symbol;
public string Symbol { get => _symbol; set { _symbol = value; OnPropertyChanged(); } }
*and for cases where you need to pass in a different name than the calling name, you can still do so, such as this:
private double _stockPrice;
public double StockPrice { get => _stockPrice; set { _stockPrice = value; OnPropertyChanged(); OnPropertyChanged(nameof(TotalPrice)); } }
Just another way to do the same thing, lol, thought I'd share. :-)
Great video series so far. I am having a bit of an issue though. When I try to load up the view model by default when starting the application, I get a stack overflow error. My App.xaml.cs is loading the main window, setting the data context to my MainViewModel, and then the navigator takes over. The navigator is instantiated and set in the MainViewModel like you have done, and in the constructor of the MainViewModel I call Navigator.UpdateViewModelCommand.Execute(ViewType.Home); as you have. When I set a breakpoint though inside of the UpdateCurrentViewModelCommand switch statement, it hits correctly as a Home Type, but that creates another view model for MainViewModel and circles back to the constructor of the MainViewModel again, and loops until I get a stackoverflow error. As far as I can tell, I have it setup like you, so I don't fully understanding what is going on here. Any insight if others might have run into this issue would be much appreciated! Thank you so much!
NVM figured it out. I was trying to use the Main View Model as my home view model too still. I changed that to load the main view model first, and then set the Navigator to use the HomeViewModel instead and it loaded fine with circling back on itself over and over again. Thanks again for the great tutorials so far!
So far this is an awesome series. Well done. Thanks, Sean.
Question: How would you handle the card display if you didn't know the number of majorindexes? Say it was a different object you were putting in the card but you weren't sure how many of them you had. How would you handle adding that to the display?
Hey ElCidPhysics, I have this issue quite frequently! The trick is to use an ItemsControl and define a custom ItemTemplate. I'm not sure I have an example of this, but I want to do a video on this. It's pretty much the equivalent of a doing a "for loop" in XAML.
@@SingletonSeanthank you. Sorry I didn’t see this earlier
HI, Is it possible to make the cards update values realtime? like every sencond, while you are in Home view?
Hey Gajaruban, that's a planned feature! To implement that, I plan to use a Timer that will ping our MajorIndexService and refresh the cards. It will be exciting.
@@SingletonSean Nice. looking forward to that. I'm great full for all your videos. Thanks.
Hey Sean,
I´m following your tutorials and they are fantastic. I would like to ask you something. Are you currently using a MVVM framework for your projects?
Cheers from México,
Sergio Camacho
Hey Sergio, currently I am not using an MVVM framework. I feel comfortable just using vanilla WPF. However, many people have asked about frameworks, so I might have to check one out! Glad to hear you're enjoying the tutorials.
@@SingletonSean Thanks for the answer. That is great to hear. I think that the frameworks just complicate things and they are a little bit overwhelming to learn. The only nuget packages that I consider very useful is the ones called Fody and PropertyChanged.Fody. They take care of the full implementation of the properties in classes that implement the INotifyPropertyChanged.
Thanks! I like it!
Anyways thanks for the content.