.net 如何开始 WPF 开发?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/129772/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to begin WPF development?
提问by Dror Helper
I've been using Winforms since .NET 1.1 and I want to start learning WPF.
我从 .NET 1.1 开始使用 Winforms,我想开始学习 WPF。
I'm looking for some good resources for a beginner in WPF. What should I read, what tools do I need, and what are the best practices I should follow?
我正在为 WPF 初学者寻找一些好的资源。我应该阅读什么,我需要什么工具,我应该遵循哪些最佳实践?
采纳答案by Brad Leach
Please have a look at this StackOverflow post, which has a list of book recommendations.
请查看此 StackOverflow 帖子,其中列出了书籍推荐列表。
In terms of best practices, get familiar with the M-V-VM pattern. It seems to have gained the most traction in WPF-land.
在最佳实践方面,熟悉MV-VM 模式。它似乎在 WPF-land 中获得了最大的吸引力。
Check out this postfor what tools you can use for WPF development.
查看这篇文章,了解可用于 WPF 开发的工具。
The MSDN Forumis a great place for resources, as is the MSDN help files on WPF.
该MSDN论坛是对资源的好地方,因为是WPF的MSDN帮助文件。
My personal recommendation is for you to forget everything you have learnt about WinForms. WPF is a totally different model, and once I finally dropped my "I did it this way in WinForms, but that way doesn't work in WPF" I had one of those "lightbulb" moments.
我个人的建议是让你忘记你学到的关于 WinForms 的一切。WPF 是一个完全不同的模型,一旦我终于放弃了我的“我在 WinForms 中这样做,但这种方式在 WPF 中不起作用”,我有一个“灯泡”时刻。
Hope this helps!
希望这可以帮助!
回答by cplotts
The learning curve is high, but there are a lot of really good resources out there. And, the MSDN documentation and SDK samples (as some have already mentioned) are really good.
学习曲线很高,但有很多非常好的资源。而且,MSDN 文档和 SDK 示例(正如某些人已经提到的)非常好。
One thing that will help you though, is just to acknowledge the learning curve up front, and to not get discouraged when it doesn't make sense. There really are a lot of concepts to 'grok' before you can do some even basic things.
但是,对您有帮助的一件事就是预先承认学习曲线,并且在没有意义时不要气馁。在您可以做一些甚至基本的事情之前,确实有很多概念需要“理解”。
The WPF books already mentioned are all valuable in their own way. My personal experience was that I got a copy of WPF Unleashedfirst and tried reading it to no avail. It wasn't until I picked up Charles Petzold's Application = Code + Markupand read through some of that ... before I could even begin to understand WPF Unleashed. However, my brain needs detail before concepts actually sink in ...
已经提到的 WPF 书籍都有自己的价值。我的个人经验是,我先拿到了WPF Unleashed的副本,并尝试阅读它但无济于事。直到我拿起 Charles Petzold 的Application = Code + Markup并通读了其中的一些内容......在我什至开始理解WPF Unleashed 之前。然而,我的大脑需要细节才能真正理解概念......
Tim Sneath has an excellent list of WPF bloggers that I have found valuable to get hooked into the WPF community: WPF Bloggers
Tim Sneath 有一个很好的 WPF 博主列表,我发现这些博主很有价值,可以加入 WPF 社区: WPF 博主
A fewblogs on my must read list:
我必读清单上的一些博客:
Another thing I would do is get Dr. WPF's snippet library (located here). This is an extremely good way to learn some of the basic plumbing type concepts like Dependency Properties, Routed Events, and Routed Commands.
我要做的另一件事是获取 Dr. WPF 的代码片段库(位于此处)。这是学习一些基本管道类型概念(如依赖属性、路由事件和路由命令)的极好方法。
Finally, I would get a copy of Blend (v2.5 is still in beta and free) and use that to generate xaml and then dive into that generated xaml to understand what you did in Blend, maps to the WPF API.
最后,我将获得 Blend 的副本(v2.5 仍处于测试版和免费版)并使用它来生成 xaml,然后深入研究生成的 xaml 以了解您在 Blend 中所做的工作,映射到 WPF API。
Hope this helps. Good luck.
希望这可以帮助。祝你好运。
回答by Jobi Joy
1 Start understanding the XAML and control heirarchies - UI markup and the new terms and features around it. KaXaml is a great tool to learn XAML, It is free to download http://www.kaxaml.com/
1 开始了解 XAML 和控件层次结构 - UI 标记以及围绕它的新术语和功能。KaXaml 是学习 XAML 的好工具,可免费下载http://www.kaxaml.com/
2 Since you have already got a long .NET experience, go directly to the SDK Samples and start running in it and see what is happeing, play with XAML. http://msdn.microsoft.com/en-us/library/ms771449.aspx
2 由于您已经获得了长期的 .NET 经验,请直接转到 SDK 示例并开始在其中运行,看看发生了什么,使用 XAML。http://msdn.microsoft.com/en-us/library/ms771449.aspx
3 If you are looking for Blog resources here is my best suggestion
3 如果您正在寻找博客资源,这里是我最好的建议
- Josh Smith - http://joshsmithonwpf.wordpress.com/
- Dr. WPF - http://www.drwpf.com/blog/
- 乔什史密斯 - http://joshsmithonwpf.wordpress.com/
- WPF 博士 - http://www.drwpf.com/blog/
But selecting a simple UI scenario which you already implemented or saw somewhere and try implementing it in WPF- That is probably the best approach to learn a new technology.
但是选择一个您已经实现或在某处看到的简单 UI 场景并尝试在 WPF 中实现它- 这可能是学习新技术的最佳方法。
And please dont get afraid of MVVM , those things will come handy later once you got familiar with WPF platform and XAML.
并且请不要害怕 MVVM,一旦您熟悉了 WPF 平台和 XAML,这些东西就会派上用场。
回答by Kevin Berridge
I'd recommend the book Windows Presentation Foundation Unleashedby Adam Nathan
我推荐Adam Nathan所著的Windows Presentation Foundation Unleashed一书
Then I'd recommend you write an application. Like every other dev environment, there are no perfect guidelines. You have to find the ones that make the most sense for your circumstance. The only way to do that is to just start coding.
那我建议你写一个应用程序。与其他所有开发环境一样,没有完美的指导方针。你必须找到最适合你的情况的那些。做到这一点的唯一方法就是开始编码。
As for tools, Visual Studio 2008 [Express] is your best bet. Or you might be able to limp along with XamlPad.
至于工具,Visual Studio 2008 [Express] 是您最好的选择。或者,您可以与 XamlPad 一起跛行。
回答by RichS
Adam Nathan's - WPF Unleashed, book is very good.
Adam Nathan 的 - WPF Unleashed,书很好。
回答by Ray
I would also highly recommend using Blend together with VS 2008. Blend is great for creating animations.
我还强烈建议将 Blend 与 VS 2008 一起使用。 Blend 非常适合创建动画。
The Blend 2.5 Previewcan be freely downloaded.
该混合2.5预览可免费下载。
I like the Designer WPF Blog, which has some good tutorials on how to do WPF stuff in Blend.
我喜欢Designer WPF 博客,其中有一些关于如何在 Blend 中执行 WPF 内容的很好的教程。
回答by Sean Sexton
I would humbly also suggest taking a look at my blog, 2,000 Things You Should Know About WPF, where I post a single piece of information on WPF each day. The blog starts with first principles and gradually works into more advanced topics, so it's a good place to start, as a beginner.
我还谦虚地建议看看我的博客,关于 WPF 你应该知道的 2,000 件事,我每天在那里发布一条关于 WPF的信息。该博客从首要原则开始,逐渐涉及更高级的主题,因此作为初学者,这是一个很好的起点。
回答by Kobi Hari
Mastering WPF (and silverlight, and basically any vector based XAML .net rich UI framework) requires more than understanding the new development concepts (and there are many). Its not enough to fully understand dependency properties, attached properties, templates, data binding, styles, MVVM, the layout mechanism, visual states and parts, effects, routed events... To really know your way around, you need to understand some basic concepts in graphics (such as vector graphics, raster graphics, rendering, layered graphics techniques, animation, pixel shaders, gradients, geometries, paths, brushes, transformation matrices, etc). In addition to that, you need to learn and understand M-V-VM which is not just a new design pattern - its a whole new programming paradigm. So there is a lot to learn... and the problem is that no matter which starting point you pick, you always feel that something is missing.
掌握 WPF(和 Silverlight,以及基本上任何基于向量的 XAML .net 富 UI 框架)需要的不仅仅是理解新的开发概念(并且有很多)。完全理解依赖属性、附加属性、模板、数据绑定、样式、MVVM、布局机制、视觉状态和部件、效果、路由事件……要真正了解自己的方法,您需要了解一些基本的知识图形中的概念(例如矢量图形、光栅图形、渲染、分层图形技术、动画、像素着色器、渐变、几何图形、路径、画笔、变换矩阵等)。除此之外,您需要学习和理解 MV-VM,这不仅仅是一种新的设计模式——它是一种全新的编程范式。所以有很多东西要学...
I tried several books as a starting point and many of them got me quite confused. Then I found "Illustrated WPF" by Daniel M. Solis and this one did the trick for me. He explains concepts from the world of graphics in a way that is clear to developers, and then teaches all the new concepts of XAML based UI while lightly touching each topic and diving into specific topics through a demo. Simply by following the tutorials, you find that you have learned a lot, and more importantly, removed the fear factor.
我尝试了几本书作为起点,其中许多书让我很困惑。然后我找到了 Daniel M. Solis 的“Illustrated WPF”,这个对我有用。他以一种对开发人员来说很清楚的方式解释了图形世界中的概念,然后教授基于 XAML 的 UI 的所有新概念,同时通过演示轻松触及每个主题并深入到特定主题。简单跟着教程,你会发现你学到了很多,更重要的是,消除了恐惧因素。
Once you master that, you can move on to "WPF Unleashed" by Adam Nathan and dive deeper. This one gives you a much more In-Depth view of the concepts that are unique to WPF, which I believe you have a much better chance of understanding once you have seen each feature at least once. They somehow all complete eachother and only make sense together.
一旦掌握了这一点,您就可以继续阅读 Adam Nathan 的“WPF Unleashed”并深入研究。这个让您更深入地了解 WPF 独有的概念,我相信一旦您至少看过一次每个功能,您就有更好的理解机会。他们不知何故都互相完善,只有在一起才有意义。
You will still have tons to learn after that, but at this point you can develop rich applications and learn new topics as you go...
在那之后你仍然有很多东西要学习,但此时你可以开发丰富的应用程序并学习新的主题......
Enjoy :-)
享受 :-)
回答by cplotts
Although already listed above, I wanted to reiterate one point.
虽然上面已经列出,但我想重申一点。
Kaxamlis bar none, the best loose xaml editor out there. It has a snippet library, IntelliSense, split view, a xaml scrubber (pretty print), and more.
Kaxaml 绝对是最好的松散 xaml 编辑器。它有一个片段库、IntelliSense、拆分视图、一个 xaml 清理器(漂亮的打印)等等。
I only wish we could hook up some assemblies (that you could reference from the xaml) ...
我只希望我们可以连接一些程序集(您可以从 xaml 中引用)...
Robby Ingebretsen, you rock.
罗比·英格布雷森,你摇滚。
回答by Jordan Parmer
Microsoft actually has a decent introduction on MSDN: http://msdn.microsoft.com/en-us/library/aa970268.aspx
微软实际上在 MSDN 上有一个不错的介绍:http: //msdn.microsoft.com/en-us/library/aa970268.aspx

