3 ms·
I have been trying to learn WPF for a long time, but have drifted into web apps. Can you point me to any good resources to be able to make complex multi window
by kumarvvr 2y ago
I have been trying to learn WPF for a long time, but have drifted into web apps.
Can you point me to any good resources to be able to make complex multi window apps in it?
I have good experience in Windoes forms and am well versed in c# and dotnet.
- Const-me 2y agoI’ve learned WPF long ago, and I no longer remember how specifically I did that. Still, that introduction seems pretty good at the first sight: https://wpf-tutorial.com/ https://wpf-tutorial.com/ Learning is easy, it’s very user friendly and IDE support is great. Mastering the framework for complicated GUI is harder. Here’s a few tips. Treat XAML the same way as any other source code. Keep it human readable: write comments (the syntax is the same as in XML i.e. <!-- A comment --> ), and use proper indentation (I often use tab size = 2 for XAML files). When a particular window or control grows too huge, consider moving large pieces into separate XAML files with a user control or maybe a resource dictionary. MVVM design pattern is great, use it whenever possible. Don’t forget to implement INotifyPropertyChanged and/or use ObservableCollection<T> for dynamic things. Having said that, I tend to avoid opinionated MVVM frameworks like Caliburn.Micro, IMO these things sacrifice simplicity for testability. Sometimes for complicated UX use cases like drag/drop or mouse painting handling these input events in code behind is way simpler than trying to stick with MVVM. Luckily these approaches compose rather well; it’s possible to use MVVM for most of the UX and code behind logic only in the few places where it simplifies things. Similarly, for diagrams or similar GUI you can directly create and manipulate these UI elements with C#, placing then on a canvas. Technically possible to do in MVVM-y way e.g. an ItemControl with a Canvas in the ItemsPanel, just much harder to do especially the layout on resize. BTW, you can define styles for these elements in XAML markup, no need to set up every possible font/brush in C#. Couple advanced features I often use are IValueConverter interface to translate values or types between views and view models, and DataTemplateSelector to programmatically switch between multiple data templates. I tend to avoid DataTrigger in XAML, I prefer exposing additional public properties from my view models.
- kumarvvr 2y agoThank you for your patient and detailed response.
- PKop 2y agoI liked this Pluralsight WPF course a lot, the instructor (Thomas Claudius Huber) is clear in his explanations and seems to be very knowledgeable. https://www.pluralsight.com/courses/wpf-6-fundamentals https://www.pluralsight.com/courses/wpf-6-fundamentals