Transitioning from Windows Forms to WPF

后端 未结 5 2131
时光取名叫无心
时光取名叫无心 2020-11-22 00:27

For a long time now, I have been stuck with Windows Forms development (started with VB6, and has continued through to C# .NET 4.5), and I have pretty much hit the limit of w

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 00:39

    I like to blog about beginner articles for WPF, and there are a few in particular that may help you out:

    • Understanding the change in mindset when switching from WinForms to WPF
    • What is this "DataContext" you speak of?
    • A Simple MVVM Example

    To summarize, the biggest difference between Winforms and WPF is that in WPF your data layer (the DataContext) is your application, while in Winforms your UI layer is your application.

    To look at it another way, with WPF your application consists of the objects you create, and you use Templates and other UI objects to tell WPF how to draw your application components.

    That's the opposite of WinForms where you build your application out of UI objects, and then supply them with the data needed.

    Because of this, the designer isn't actually used that much since your application components are designed in code, and the designer is only needed to draw a user-friendly interface that reflects your data classes (typically Models and ViewModels)

    And personally, I prefer to type all my XAML out by hand since it's faster and doesn't make as much of a mess as the drag/drop WPF designer does, although I do use the Designer on occasion to preview what my UI will look like.

    So to your answer your question about if there's other WPF designers suited for WinForms developers, I would suggest that instead of looking for another designer, instead look to learn how to use WPF in the way it's meant to be used. Using WPF like it's WinForms means you miss out on much of what makes it so great :)

提交回复
热议问题