学习WPF和MVVM -从零开始学习的最佳方法

时间:2023-01-29 22:06:42

I've got about three years c# experience. I'd like to learn some WPF and the MVVM pattern. There are a lot of links to articles on this site but I'm getting a little overwhelmed. Would a sensible approach for a begginer to be forget mvvm for a while and just quickly learn a bit a of WPF, then come back to MVVM?

我有三年的c#经验。我想学习一些WPF和MVVM模式。这个网站上有很多文章链接,但是我有点不知所措。对于乞丐来说,明智的做法是暂时忘记mvvm,然后快速学习一点WPF,然后再回到mvvm ?

I had a leaf through Application=Code+Markup - Charles Petzold in work today, it doesn't seem to mention MVVM (at least not in the index). I was pretty surprised by this as I thought MVVM was supposed to be the "lingua franca" of WPF?

我曾经读过Application=Code+Markup - Charles Petzold的文章,它似乎没有提到MVVM(至少在索引中没有)。我很惊讶,因为我认为MVVM应该是WPF的“通用语言”?

Also I've just started working at a new company and they are using MVVM with WinForms, has anyone come across this before?

我刚开始在一家新公司工作,他们正在用MVVM和WinForms,有人见过吗?

Can anyone recommend a book that will teach me both WPF and MVVM?

谁能推荐一本教我WPF和MVVM的书?

8 个解决方案

#1


26  

It depends on your experience.

这取决于你的经验。

I personally felt that this was a lacking area in MVVM discussions, which was what led me to write my series on MVVM and WPF from a Windows Forms developer perspective.

我个人觉得这是MVVM讨论中缺少的一个领域,这让我从Windows窗体开发人员的角度来编写我的MVVM和WPF系列。

I would not try to learn WPF without learning MVVM. You'll end up trying to "unlearn" many aspects, as WPF really doesn't make sense, completely, until you understand the separation of presentation and logic that's pervasive throughout the architecture. MVVM is really just extending this same separation into the application space.

我不会在没有学习MVVM的情况下学习WPF。最后,您将尝试“取消学习”许多方面,因为WPF确实没有任何意义,除非您理解整个体系结构中普遍存在的表示和逻辑的分离。MVVM实际上只是将这种分离扩展到应用程序空间中。

As for "MVVM in Windows Forms" - a lot of people try to do this, but it's not really MVVM. In order to do "MVVM" you need access to a richer form of data binding than Windows Forms provides. "MVVM in Windows Forms" is really, typically, just Model-View-Presenter with a different name (riding the MVVM bandwagon, I'd guess), but not really the same as MVVM in WPF.

至于“Windows窗体中的MVVM”——很多人都想这么做,但这并不是真正的MVVM。为了实现“MVVM”,您需要访问比Windows窗体提供的更丰富的数据绑定形式。“Windows窗体中的MVVM”实际上只是一个名称不同的模型-视图演示程序(我猜是乘上了MVVM的潮流),但与WPF中的MVVM并不完全相同。

#2


11  

Jason Dolinger has an excellent video on the subject. It steps you through the process moving from using code behind files to a full MVVM pattern including Dependency Injection and Testing.

Jason Dolinger有一个关于这个主题的优秀视频。它将您从使用文件后面的代码过渡到完整的MVVM模式(包括依赖注入和测试)的过程。

Bill Steele did a 16 part "Soup-to-Nuts" webcast series on WPF. The links on the msevents site are broken. Here is a Google search to find them. This will help with the WPF learning curve. And he does NOT use any MV* patterns in his examples.

比尔·斯蒂尔在WPF上做了一个16部分的网络直播。msevents网站的链接被破坏了。这里是谷歌搜索以找到它们。这将有助于WPF的学习曲线。他没有在例子中使用任何MV*模式。

EDIT: The MSEvents links are working now, I am leaving the Google search as a backup.

编辑:MSEvents链接现在正在运行,我将退出谷歌搜索作为备份。

Josh Smith also has an excellent article WPF Apps With The Model-View-ViewModel Design Pattern on MSDN.

Josh Smith还有一篇优秀的文章WPF应用,在MSDN上有模型-视图-视图模型设计模式。

Herding Code: Presentation Patterns with Jeremy Miller, Ward Bell, Rob Eisenberg and Glenn Block

集合代码:与Jeremy Miller、Ward Bell、Rob Eisenberg和Glenn Block的演示模式

MIX10:

MIX10:

And of course Reed Copsey's MVVM articles are worth a read as well.

当然,Reed Copsey的MVVM文章也值得一读。

#3


6  

I was told a few times that my MIX10 session was explaining the MVVM pattern well enough for beginners (even though some parts are actually quite advanced, so don't worry if you need to re-watch certain parts).

有人告诉我,我的MIX10会议是为初学者解释MVVM模式的(尽管有些部分实际上是相当高级的,所以如果需要重新观察某些部分,请不要担心)。

The session is at http://live.visitmix.com/MIX10/Sessions/EX14

会话位于http://live.visitmix.com/MIX10/Sessions/EX14

Sorry for the self-promotion.

抱歉的自我推销。

Cheers, Laurent

欢呼,劳伦

#4


4  

There aren't many books covering MVVM but there is one : Advanced MVVM

关于MVVM的书不多,但有一本:高级MVVM

But there are lots of online resources and this one is a must read : WPF Apps With The Model-View-ViewModel Design Pattern

但是有很多在线资源,这是必须阅读的:WPF应用程序,具有模型-视图-视图-视图模型设计模式

After that I suggest looking into frameworks like

之后,我建议研究类似的框架

#5


1  

Here is a tutorial for MVVM http://www.codeproject.com/Articles/819294/Learn-WPF-MVVM-step-by-step-Basics-to-Advance-Leve which goes from basic to the advance level in 5 steps. So its like graduating from a 3 layer to full MVVM.

这里有一个MVVM的教程http://www.codeproject.com/articles/819294/learn - wpf -MVVM-step-by- basics -to- advance - leve,它在5个步骤中从基本到高级。这就像从一个3层过渡到完全的MVVM。

学习WPF和MVVM -从零开始学习的最佳方法

#6


1  

To do big things (like learning WPF + MVVM) it is better to break the task in smaller steps.

要做大事(比如学习WPF + MVVM),最好是用更小的步骤来完成任务。

I think that the best approach in this situation is to start by learning the UI part of Wpf. Learn XAML syntax, the layout system, the available controls and forget about binding and how to deliver data to the controls.

我认为在这种情况下最好的方法是从学习Wpf的UI部分开始。学习XAML语法、布局系统、可用控件和忘记绑定以及如何向控件交付数据。

Once you know the UI basics of Wpf then it is time to move to MVVM. Learn how bindings work and the MVVM pattern.

一旦您了解了Wpf的UI基础知识,那么就该迁移到MVVM了。了解绑定如何工作以及MVVM模式。

In this Web you can find a tutorial focusing on the hands on but with the theory available:

在这个网络中,你可以找到一个专注于手的教程,但是有了理论:

http://www.learnmvvm.com

http://www.learnmvvm.com

#7


0  

Try this site. It collects the various resources at one place. http://learnandmasterwpf.blogspot.com/

试试这个网站。它在一个地方收集各种资源。http://learnandmasterwpf.blogspot.com/

#8


0  

I just read this book. It is not really about learning WPF, but it should be useful once you already know a bit of WPF and want to progress your understanding of MVVM.

我刚看了这本书。它并不是真正关于学习WPF,但是如果您已经了解了一些WPF,并且希望进一步了解MVVM,那么它应该是有用的。

http://www.amazon.co.uk/Pro-WPF-Silverlight-MVVM-Model-View-ViewModel/dp/1430231629

http://www.amazon.co.uk/Pro-WPF-Silverlight-MVVM-Model-View-ViewModel/dp/1430231629

#1


26  

It depends on your experience.

这取决于你的经验。

I personally felt that this was a lacking area in MVVM discussions, which was what led me to write my series on MVVM and WPF from a Windows Forms developer perspective.

我个人觉得这是MVVM讨论中缺少的一个领域,这让我从Windows窗体开发人员的角度来编写我的MVVM和WPF系列。

I would not try to learn WPF without learning MVVM. You'll end up trying to "unlearn" many aspects, as WPF really doesn't make sense, completely, until you understand the separation of presentation and logic that's pervasive throughout the architecture. MVVM is really just extending this same separation into the application space.

我不会在没有学习MVVM的情况下学习WPF。最后,您将尝试“取消学习”许多方面,因为WPF确实没有任何意义,除非您理解整个体系结构中普遍存在的表示和逻辑的分离。MVVM实际上只是将这种分离扩展到应用程序空间中。

As for "MVVM in Windows Forms" - a lot of people try to do this, but it's not really MVVM. In order to do "MVVM" you need access to a richer form of data binding than Windows Forms provides. "MVVM in Windows Forms" is really, typically, just Model-View-Presenter with a different name (riding the MVVM bandwagon, I'd guess), but not really the same as MVVM in WPF.

至于“Windows窗体中的MVVM”——很多人都想这么做,但这并不是真正的MVVM。为了实现“MVVM”,您需要访问比Windows窗体提供的更丰富的数据绑定形式。“Windows窗体中的MVVM”实际上只是一个名称不同的模型-视图演示程序(我猜是乘上了MVVM的潮流),但与WPF中的MVVM并不完全相同。

#2


11  

Jason Dolinger has an excellent video on the subject. It steps you through the process moving from using code behind files to a full MVVM pattern including Dependency Injection and Testing.

Jason Dolinger有一个关于这个主题的优秀视频。它将您从使用文件后面的代码过渡到完整的MVVM模式(包括依赖注入和测试)的过程。

Bill Steele did a 16 part "Soup-to-Nuts" webcast series on WPF. The links on the msevents site are broken. Here is a Google search to find them. This will help with the WPF learning curve. And he does NOT use any MV* patterns in his examples.

比尔·斯蒂尔在WPF上做了一个16部分的网络直播。msevents网站的链接被破坏了。这里是谷歌搜索以找到它们。这将有助于WPF的学习曲线。他没有在例子中使用任何MV*模式。

EDIT: The MSEvents links are working now, I am leaving the Google search as a backup.

编辑:MSEvents链接现在正在运行,我将退出谷歌搜索作为备份。

Josh Smith also has an excellent article WPF Apps With The Model-View-ViewModel Design Pattern on MSDN.

Josh Smith还有一篇优秀的文章WPF应用,在MSDN上有模型-视图-视图模型设计模式。

Herding Code: Presentation Patterns with Jeremy Miller, Ward Bell, Rob Eisenberg and Glenn Block

集合代码:与Jeremy Miller、Ward Bell、Rob Eisenberg和Glenn Block的演示模式

MIX10:

MIX10:

And of course Reed Copsey's MVVM articles are worth a read as well.

当然,Reed Copsey的MVVM文章也值得一读。

#3


6  

I was told a few times that my MIX10 session was explaining the MVVM pattern well enough for beginners (even though some parts are actually quite advanced, so don't worry if you need to re-watch certain parts).

有人告诉我,我的MIX10会议是为初学者解释MVVM模式的(尽管有些部分实际上是相当高级的,所以如果需要重新观察某些部分,请不要担心)。

The session is at http://live.visitmix.com/MIX10/Sessions/EX14

会话位于http://live.visitmix.com/MIX10/Sessions/EX14

Sorry for the self-promotion.

抱歉的自我推销。

Cheers, Laurent

欢呼,劳伦

#4


4  

There aren't many books covering MVVM but there is one : Advanced MVVM

关于MVVM的书不多,但有一本:高级MVVM

But there are lots of online resources and this one is a must read : WPF Apps With The Model-View-ViewModel Design Pattern

但是有很多在线资源,这是必须阅读的:WPF应用程序,具有模型-视图-视图-视图模型设计模式

After that I suggest looking into frameworks like

之后,我建议研究类似的框架

#5


1  

Here is a tutorial for MVVM http://www.codeproject.com/Articles/819294/Learn-WPF-MVVM-step-by-step-Basics-to-Advance-Leve which goes from basic to the advance level in 5 steps. So its like graduating from a 3 layer to full MVVM.

这里有一个MVVM的教程http://www.codeproject.com/articles/819294/learn - wpf -MVVM-step-by- basics -to- advance - leve,它在5个步骤中从基本到高级。这就像从一个3层过渡到完全的MVVM。

学习WPF和MVVM -从零开始学习的最佳方法

#6


1  

To do big things (like learning WPF + MVVM) it is better to break the task in smaller steps.

要做大事(比如学习WPF + MVVM),最好是用更小的步骤来完成任务。

I think that the best approach in this situation is to start by learning the UI part of Wpf. Learn XAML syntax, the layout system, the available controls and forget about binding and how to deliver data to the controls.

我认为在这种情况下最好的方法是从学习Wpf的UI部分开始。学习XAML语法、布局系统、可用控件和忘记绑定以及如何向控件交付数据。

Once you know the UI basics of Wpf then it is time to move to MVVM. Learn how bindings work and the MVVM pattern.

一旦您了解了Wpf的UI基础知识,那么就该迁移到MVVM了。了解绑定如何工作以及MVVM模式。

In this Web you can find a tutorial focusing on the hands on but with the theory available:

在这个网络中,你可以找到一个专注于手的教程,但是有了理论:

http://www.learnmvvm.com

http://www.learnmvvm.com

#7


0  

Try this site. It collects the various resources at one place. http://learnandmasterwpf.blogspot.com/

试试这个网站。它在一个地方收集各种资源。http://learnandmasterwpf.blogspot.com/

#8


0  

I just read this book. It is not really about learning WPF, but it should be useful once you already know a bit of WPF and want to progress your understanding of MVVM.

我刚看了这本书。它并不是真正关于学习WPF,但是如果您已经了解了一些WPF,并且希望进一步了解MVVM,那么它应该是有用的。

http://www.amazon.co.uk/Pro-WPF-Silverlight-MVVM-Model-View-ViewModel/dp/1430231629

http://www.amazon.co.uk/Pro-WPF-Silverlight-MVVM-Model-View-ViewModel/dp/1430231629