wpf 如何在 windows 窗体应用程序上实现漂亮的用户界面,如网站?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27966570/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 12:50:50  来源:igfitidea点击:

How to achieve beautiful user interface like website on windows form app?

c#wpfwinformsuser-interface

提问by Charlie

I have done a lot work on windows forms, In the past user interfaces were not important, but this time it is important. I want to create a windows form app that has a great interface, like a beautiful website.

我在windows窗体上做了很多工作,过去用户界面并不重要,但这次很重要。我想创建一个具有出色界面的 windows 窗体应用程序,就像一个漂亮的网站。

shown one example below example website

下面显示了一个示例 示例网站

Can I achieve this by any means in visual studio 2010? I don't have any experience of WPF, is it achievable there?

我可以在 Visual Studio 2010 中以任何方式实现这一目标吗?我没有任何 WPF 的经验,在那里可以实现吗?

回答by Sinatr

Yes, you can do this and much more in WPF (consider nice animations when you mouse-over or click items, or when tab changes, etc). Do not even try winforms, there are paid libraries, which can provide you with components to create rich user interface, but winforms is not flexible in any way by itself. In wpf you can achieve EXACTLY look you want.

是的,您可以在 WPF 中执行此操作以及更多操作(当您将鼠标悬停或单击项目时,或选项卡更改等时,请考虑漂亮的动画)。甚至不要尝试winforms,有付费库,可以为您提供创建丰富用户界面的组件,但是winforms本身并不灵活。在 wpf 中,您可以完全实现您想要的外观。

Specifically to screenshot:

具体来截图:

  • On top is some ItemsControlwith items (DataTemplate) what has restyled checkbox (or vector graphics) and background bound to current item.
  • Below is ContentControl, which takes data template for current item (UserControl).
  • Actual content is simple restyled standard controls, it's very easy to make them looks like this.
  • 顶部是一些ItemsControl项目 ( DataTemplate) 重新设计了复选框(或矢量图形)和绑定到当前项目的背景。
  • 下面是ContentControl,它采用当前项目 ( UserControl) 的数据模板。
  • 实际内容是简单的重新设计的标准控件,很容易让它们看起来像这样。

回答by Mert Akcakaya

Windows Forms is a legacytechnology and does not provide you good tools to create your good looking custom controls. You need to work with low level API's to draw your controls like GDI+. If you are eager to learn, it is not that hard. It is indeed fun to work with GDI+ drawing shapes and painting them etc, but it will cost you a lot of time and it probably won't look too good.

Windows 窗体是一项传统技术,并没有为您提供创建美观的自定义控件的良好工具。您需要使用低级 API 来绘制GDI+等控件。如果你渴望学习,这并不难。使用 GDI+ 绘制形状并绘制它们等确实很有趣,但这会花费您很多时间,而且可能看起来不太好。

Other than that if you want to stick with Windows Forms but develop your UI quickly, you can use DevExpressor Teleriklibraries but they cost a lot of money.

除此之外,如果你想坚持使用 Windows 窗体但快速开发你的 UI,你可以使用DevExpressTelerik库,但它们会花费很多钱。

As Sinatr said, the most common way is to go with WPF. You will access powerful tools like Blendand a modern API to create and customize your set of controls. You can still utilize DevExpress and Telerik control in WPF.

正如 Sinatr 所说,最常见的方法是使用WPF。您将使用Blend和现代 API等强大的工具来创建和自定义您的控件集。您仍然可以在 WPF 中使用 DevExpress 和 Telerik 控件。