What is WPF and how does it compare to WinForms?

前端 未结 7 1950
星月不相逢
星月不相逢 2021-01-30 05:02

I\'ve been looking at WPF, but I\'ve never really worked in it (except for 15 minutes, which prompted this question). I looked at this post but its really about the \"Flash\" of

相关标签:
7条回答
  • 2021-01-30 05:37

    To answer your question, a WPF application is a Windows application. WPF is Microsoft's new framework (actually, it is a subsystem of the .NET framework 3.0) for writing rich Windows applications. It is meant as an eventual replacement for WinForms (although admittedly the adoption rate is much slower than MS hoped for).

    0 讨论(0)
  • 2021-01-30 05:37

    From an implementation perspective, one of the main differences is that WPF uses a strictly enforced model-view-viewmodel M-V-VM architecture, with the view being defined in a custom markup language, XAML, the viewmodel being a class with accessible properties, and the model effectively being the data access layer. WinForms, by comparison, has no such explicit separation - although by convention the different aspects may be grouped in different C# files, its all still code. In practice this makes WPF development more like web DOM development, with the WPF framework running in the background and mediating.

    0 讨论(0)
  • 2021-01-30 05:45

    Start here, there's dozens and dozens of videos: http://www.windowsclient.net/learn

    In this case, the marketing schpiel is pretty good:

    **"Windows Forms is a set of classes in the .NET Framework that enables rapid development of rich Windows client applications, with powerful, extensible libraries for user-interface controls and graphics. You can incorporate WPF in your Windows Forms applications through WPF-Windows Forms interoperability in the .NET 3.5 Framework."*

    *"WPF, a component of Microsoft .NET Framework 3.5, empowers you to build the next-generation of Windows user experiences. WPF supports UI, media, documents, hardware acceleration, vector graphics, scalability to different form factors, interactive data visualization, and superior content readability."**

    With WPF you get WAY better graphics support, way more powerful and flexible databinding (if you're working with Data, use WPF.)

    0 讨论(0)
  • 2021-01-30 05:47

    A good way of looking at this might start with asking what exactly Winforms is.

    Both Winforms and WPF are frameworks designed to make the UI layer of an application easier to code. The really old folks around here might be able to speak about how writing the windows version of "Hello, World" could take 4 pages or so of code. Also, rocks were a good deal softer then and we had to fight of giant lizards while we coded. The Winforms library and designer takes a lot of the common tasks and makes them easier to write.

    WPF does the same thing, but with the awareness that those common tasks might now include much more visually interesting things, in addition to including a lot of things that Winforms did not necessarily consider to be part of the UI layer. The way WPF supports commanding, triggers, and databinding are all great parts of the framework, but the core reason for it is the same core reason Winforms had for existing in the first place.

    WPFs improvement here is that, instead of giving you the option of either writing a completely custom control from scratch or forcing you to use a single set of controls with limited customization capabilities, you may now separate the function of a control from its appearance. The ability to describe how our controls look in XAML and keep that separate from how the controls work in code is very similar to the HTML/Code model that web programmers are used to working with.

    A good WPF application follows the same model that a good Winforms application would; keeping as much stuff as possible out of the UI layer. The core logic of the application and the data layer should be the same, but there are now easier ways of making the visuals more impressive, which is likely why most of the information you've seen on it involves the flashier visual stuff. If you're looking to learn WPF, you can actually start by using it almost exactly as you would Winforms and then refactoring the other features in as you grasp them. For an excellent example of this, I highly recommend Scott Hanselman's series of blog posts on the development of BabySmash, which start here. It's a great walkthrough of the process, both in code and in thought.

    0 讨论(0)
  • 2021-01-30 05:47

    WPF stands for Windows Presentation Foundation. While WinForms technology depends on GDI/GDI+, WPF is built directly on top of DirectX. That means you can do much more than you can with WinForms, while getting still using the .NET Framework Class library. You can build rich user interfaces, 2D/3D games, presentations and much more. WPF is much like a Flash (swf) movie, without the element "Movie". WPF is based on .NET and can be used to build rich client side web enabled applications.

    0 讨论(0)
  • 2021-01-30 05:55
    1. WPF is essentially a new API for creating a Graphical User Interfaces for the Windows Platform.
    2. WPF is more than just a next-generation presentation system for building Windows Client application along with visually stunning user interfaces.
    3. WPF is builds on top of the DirectX (Direct3D), instead of relying on the older GDI/GDI+ subsystem.
    4. WPF is a vector graphics based UI presentation layer and being vector based it allows the presentation layer to smoothly scale UI elements to any size without distortion.
    5. WPF is “skin-able” and “theme-able”. It means WPF allows changing the look and feel of any UI control.
    0 讨论(0)
提交回复
热议问题