ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Wanted: Recommendations for learning WPF (with C#)

(1/2) > >>

Deozaan:
I'd like to make a program with a UI. The content of the UI will not be static, but will change based on input from the user. What I mean by that is that the number of things shown can increase or decrease based on what the user does. For example, a to-do list might only show a few items, or it may show many items.

I'm thinking that since I program in C# I should use WPF for the UI. If anyone here is experienced with making GUI applications in C# and can tell me why I shouldn't go with WPF, I'd be glad to hear your reasons why and what alternative I should use.

Otherwise, I'm looking for recommendations on good resources for learning how to use WPF to make GUI applications. Free is preferred. And I think I'd prefer the information in written/image format (e.g., a book or website) rather than video format. But I'm open to hearing any useful suggestions or recommendations of learning materials people here have found useful.

Thanks in advance!

wraith808:
Are you tied to desktop?  That's the only reason I can think of for not using WPF.  If it's desktop, I'd definitely recommend it, and look into MVVM- that's what I use for a more reactive interface and to decouple the interface from the logic.  It seems like it might be a good thing for your use case.

As far as learning- I'd personally suggest using XAML instead of the visual editor.  Just like with other visual editors, the WPF design canvas can create some pretty shitty code.  And when you need to do something, you find that it screws with the whole interface.

If you want to start with the visual editor, there are a variety of courses:

https://www.wpftutorial.net/LearnWPFin14Days.html
https://www.wpf-tutorial.com/
https://www.guru99.com/wpf-tutorial.html
https://www.tutorialspoint.com/wpf/index.htm

That's just a few of them.  Of those, I like wpf-tutorial.com the best.  There are better paid ones, but that one does the job.  I'd also suggest https://www.c-sharpcorner.com/UploadFile/6f0898/learn-important-wpf-xaml-concepts-in-15-minutes/ after that, to reinforce some of the concepts, no matter which one you choose.

If you want to go the XAML route, I'd go with tutorialspoint - https://www.tutorialspoint.com/xaml/index.htm

That rolls in all of the concepts for that c-sharpcorner article also, making it an unnecessary read at that point.

One thing to note- all of these are pretty old.  Other than the format of visual studio, that shouldn't matter though.

Deozaan:
I'm not necessarily tied to Desktop, and there's a part of me that kind of likes the idea of being able to access the information from various devices or even collaboratively with others. But I have no idea how to do any of that, aside from making it web-based, and I don't really enjoy making web front-end stuff, or back-end server stuff for that matter. I suppose I could just write it in Unity, which I'm familiar enough with the UI system and it has built-in cross-platform build support. But it seemed like a waste of computing resources to use a 3D game engine to run what is (or should be) a simple, lightweight GUI application. So I'll be happy to settle for a "portable" desktop app I can run and maybe sync via Dropbox if I need to access it across devices or share it with others. Hence my foray into WPF. If I get really serious about the idea of running it on mobile devices at some future time, then maybe I'll try porting the code back into Unity or come up with some other plan. I'll cross that bridge when/if I ever get that far.

So, thanks for the links, wraith808! I'll start looking through them.



In the meantime, here are some other resources I've looked at, in case it helps others who may come across this thread in the future.

At the beginning of this year, I wanted to clean up a GUI app I had hacked together for (NANY 2018) using the visual editor when I had absolutely no idea what I was doing, so I searched for some tutorial videos on YouTube and came across Tim Corey's channel. I watched a few of his videos, including:

Intro to WPF: Learn the basics and best practices of WPF for C#


I found the above video to be a good primer on WPF. It, too, recommended typing in the XAML manually rather than using the visual editor. After I finished that one, I wanted to learn more and the next suggested video from his channel was:

WPF in C# with MVVM using Caliburn Micro


I don't think I finished watching all of the above video, mostly because I was such a noob a lot of it was going over my head, and it seemed like a lot of time and effort to learn about MVVM when all I really wanted at the time was to fix a few relatively minor issues with my hacked together GUI on my older program.

With both of those videos being over an hour long, I was afraid of asking for more video tutorials here because I didn't like the idea of spending 40-60 hours watching a video course/tutorial to learn. But I thought that perhaps other tutorial videos could exist that didn't require such a time commitment or at least divided up the content into relatively more bite-sized chunks. So today I did another search looking for comprehensive, but short(er) videos. What I found appears to reinforce my initial suspicion that video tutorials will require a fairly significant time investment. For example, I found this 45-video playlist by AngelSix on YouTube, where each video appears to be approximately 1 hour long on average.

WPF UI Programming


I did watch that first video in the series and it also recommended writing the XAML manually for similar reasons. Video #3 in the playlist will cover some MVVM basics as well, so that means three out of three sources so far have recommended writing XAML directly and using MVVM.

wraith808:
Though he calls using your own MVVM framework like "Building a car in order to drive it," taking a brief look at that video, it's a lot harder than what I do to configure that framework.  I'll try to write something simple I can put on github that illustrates how I do it.  No promises on the timeline though... unfortunately, I have a lot on my plate right now.

One other thing I'll say, and I'm not sure that most of the tutorials recommend it though it's the way I've started writing my XAML in most cases - make liberal use of DockPanel and StackPanel.  They make organizing your controls a lot simpler, IMO.

Deozaan:
I'll try to write something simple I can put on github that illustrates how I do it.  No promises on the timeline though... unfortunately, I have a lot on my plate right now.
-wraith808 (July 22, 2020, 07:50 AM)
--- End quote ---

If you can manage it, great! If not, no worries. My foray into WPF is mostly to satisfy my curiosity or learn a new skill as a hobby than for anything immediately important.


One other thing I'll say, and I'm not sure that most of the tutorials recommend it though it's the way I've started writing my XAML in most cases - make liberal use of DockPanel and StackPanel.  They make organizing your controls a lot simpler, IMO.
-wraith808 (July 22, 2020, 07:50 AM)
--- End quote ---

The first video in the above AngelSix WPF UI Programming playlist says he thinks of virtually everything in terms of either Grid or StackPanel. I'm unfamiliar with the DockPanel, but I'll be sure to learn more about it to see how it can be useful. Thanks for the tip!

Navigation

[0] Message Index

[#] Next page

Go to full version