使用 C# 进行 Windows 窗体或 WPF 开发,哪个是最佳选择?

发布于 2024-09-24 06:22:30 字数 141 浏览 2 评论 0原文

在学习C#语言时。如今所有的应用程序都在开发中。我最好专注于 Windows 窗体开发还是 WPF 开发。我想开发使用 ADO.net 进行 SQL Server 数据库访问的软件。还可以与 Microsoft Office 集成的独立应用程序来创建图表和图形等...

When learning the C# language. With all the applications being developed these days. Would I be better off focusing on windows forms development or WPF development. I want to develop software that uses ADO.net for SQL Server database access. Also stand alone applications to integrate with Microsoft Office to create charts and graphs etc...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

小女人ら 2024-10-01 06:22:30

尽管就 Windows UI 而言,两者可以实现相似的结果,但它们的功能和目的一样是相互独立的。

WinForms 是久经考验的、真实的,由于根基深厚而不会进化。这并不意味着 WinForms 已被弃用。这只是意味着 WinForms 的基础类已经完善且灵活。请记住通过 Control 类和深度工程 UI 消息传递(通过 WinForms 类公开的句柄)扩展 WinForms 的灵活性。

然而,WPF 是一个用于设计用户界面的抽象层,不一定或专门用于设计 Windows 用户界面。最难跨越的障碍是从基于坐标的用户界面(像素/位图/索引)的思想过渡到基于矢量的用户界面,其中 WPF 可以适应几乎任何大小的控件或渲染平面。

WPF 的好处是您可以学习应用程序的三种不同目标 - Windows UI、SilverLight 和现在的 Windows Phone。 WinForms 面向 Windows UI 和 Windows Mobile (CE)。基于常见小部件的干净 UI 在 WinForms 中具有适当的基础。如果您的目标是自定义的动态 UI,请尝试一下 WPF。

Although for the purposes of Windows UI that both can achieve similar results, their function is independent of one another as is their purpose.

WinForms is tried and true, non-evolving due to strong roots. It does not mean WinForms is deprecated. It just means that the foundation classes for WinForms are well established and flexible. Keep in mind the flexibility in extending WinForms via the Control class and deep-engineering UI messaging (via handles exposed by the WinForms classes).

WPF however is an abstraction layer to design user interfaces, not necessarily or exclusively Windows user interfaces. The most difficult hurdle to leap is transitioning from the thought of coordinate based user interfaces (pixel/bitmap/index) to vector based user interfaces where WPF can adapt to virtually any size control or plane of rendering.

The benefit of WPF is that you're learning three different targets for your applications - Windows UI, SilverLight, and now Windows Phone. WinForms targets Windows UI and Windows Mobile (CE). A clean UI based on common widgets has an appropriate foundation in WinForms. If a customized, dynamic UI is your target, take WPF for a spin.

伏妖词 2024-10-01 06:22:30

我会使用 WPF,因为它还允许您使用相同的 XAML 标记来执行 Silverlight 应用程序。

话虽如此,课程有多种,因此您需要为工作选择合适的工具。这确实意味着您需要了解两者才能做出明智的决定。 :)

I'd be using WPF as it also allows you to do Silverlight applications using the same XAML markup.

Having said that, there are horses for courses so you need to choose the appropriate tool for the job. That does mean you need to know both to make an informed decision. :)

染柒℉ 2024-10-01 06:22:30

WPF 的学习曲线肯定要陡峭得多 - 同时您可以轻松地在 Windows 窗体中创建一些简单的 UI 来满足您对 ADO.net 或 SQL Server 数据库访问的需求。一旦您将图表/图形添加到组合中,您就会想要轻松地学习 WPF。

此外,您可能还想看看 Lightswitch,它可以解决 Silverlight/WPF 的一些复杂性。

The learning curve with WPF is definitely much steeper - at the same time you can easily whip up some simple UI in Windows Forms to fill your needs in regards to ADO.net or SQL Server database access. Once you add charts/graphs to the mix, you are going to want to learn WPF hands down though.

Also you might want to look at Lightswitch, which takes care of some of the complexity with Silverlight/WPF.

别忘他 2024-10-01 06:22:30

尽管 WPF 是未来并且它为您提供了如此多的灵活性,但我不建议完全切换到 WPF。此外,如果您有一位能够从事设计部分工作的设计师,您将能够充分利用 WPF。我并不是说您需要一名设计人员,但根据我使用 WPF 的经验,如果您想开发一款外观出色的应用程序,那么您肯定需要一名了解 WPF 细节的设计人员。正如 BrokenGlass 所说,WPF 的学习曲线太陡了。因此,只需进行渐进式切换即可。如果您已经有一些 Windows 窗体应用程序,请尝试在 WPF 中重写其中一些应用程序。

Though WPF is the future and it gives you so much flexibility, I don't recommend switching completely to WPF. Also, you will be able to make the most out of WPF if you have a designer that will be able to work on the design part. I'm not saying you need to have a designer but based on my experience with WPF, if you want to develop a killer looking application, you definitely need to have some one that knows the bits and bytes of WPF. Just as BrokenGlass said, the learning curve with WPF is too steep. So, just make a gradual switch. If you already have some Windows Form applications, try to rewrite some of those in WPF.

苏辞 2024-10-01 06:22:30

您想要做的事情可以使用 WinForms 和 WPF 来完成。 WinForms 是一个更熟悉的范例,但(大但)XAML 一般来说,特别是 WPF,不是未来,而是当前在 .NET 中执行 Windows UI 的方式,WinForms 已经过去了,它基本上是在维护模式(适用于现有应用程序,我敢说对于新应用程序来说已过时)。是的,XAML 的学习曲线有些陡峭,但是你获得的能力是值得付出努力的,此外,关于 XAML/WPF/Silverlight 的资源(书籍、库)越来越多,而对于 WinForms,有很多但停滞不前(我还没有)几年内没有看到任何新版本的 WinForms 书籍)。值得注意的一件事是 XAML 的数据绑定功能,它使得许多不必要的代码将数据从对象/数据集移至可视控件或从可视控件移至对象/数据集。

The kind of stuff you're trying to do can be done with both WinForms and WPF. WinForms is a more familiar paradigm but (big but) XAML in general, WPF in particular, is not the future but the current way of doing Windows UI's in .NET, WinForms being the past it is basically in maintenance mode (good for existing apps, dare I say obsolete for new apps). Yes, XAML posses a somewhat steep learning curve, but the abilities you get are worth the effort, besides there are more and more resources (books, libraries) on XAML/WPF/Silverlight while for WinForms there are plenty but stagnant (I haven't seen any new edition of a WinForms book in a couple of years). One thing worth noting is the databinding capacities of XAML which render unnecesary many of the code moving data from/to objects/datasets to/from visual controls.

一抹苦笑 2024-10-01 06:22:30

WPF 和 XAML 是一个学习曲线,但我的经验是可以在更短的时间内构建更强大、简洁且可支持的应用程序。可以将 XAML 从一个页面复制并粘贴到另一个页面。在 Windows 窗体上,我放弃了将 UI 元素从一个页面(窗体)复制和粘贴到另一个页面的操作,因为它多次锁定整个应用程序。双向数据绑定是一个梦想。 WPF UI 具有更商业级的外观。 Silverlight 的可移植性。对我来说,这相当于我从 C++ 中只需付出一小部分努力就能获得的 98% 的成果。

WPF and XAML is a learning curve but my experience is can build more powerful, concise, and supportable applications in in less time. Can copy and paste XAML from one page to another. On Windows Forms I gave up on copy and past of UI elements from one page (form) to another as too many times it locked the whole app. Two way data binding is a dream. WPF UI has a more commercial grade look. Portability to Silverlight. For me it is 98% of what I would get from C++ in a fraction of the effort.

鹿港小镇 2024-10-01 06:22:30

由于您的主要目标是学习 C#,因此您应该更多地关注语言功能而不是 UI。您应该尝试学习和使用 C# 的各种功能以及它支持的内容和方式。学习(C#)将更多地用于开发应用程序的业务层和数据层,而不是您的 UI;所以你应该首先集中精力构建这些层(使用任何演示框架)。

我不确定您之前是否有任何控制台应用程序、WinForms、WPF 或 ASP.net 的经验,但出于学习目的,您应该选择您最熟悉的一个。如果您是新手,那么我建议您首先从 WinForms 开始,因为您将在 WinForms 中编写大量 C# 代码,然后在 WPF 中编写,然后再选择 WPF。

我的回答完全集中在这样的事实上:你的主要目标是学习 C#,而不是哪个 UI 框架更好等等。

As your prime objective is to learn C# you should concentrate more on language features rather then your UI. You should try to learn and use various features of C# and what all it supports and how. Learning(C#) will be much more in developing Business layer and Data layer of your application rather then your UI; so you should concentrate on building these layers first(with any presentation framework).

I am not sure whether you have any prior experience in any of console applications, WinForms, WPF or ASP.net but for learning purpose you should pick one you are most comfortable with. In case you are starting a fresh then I would suggest you to first start with WinForms as you will be writing a lot of C# code in WinForms then in WPF, and later pick up WPF.

My answer is totally focused on fact that your prime goal is to learn C# and not on which UI framework is better etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文