What is the difference between WPF and WinForms?

前端 未结 7 961
春和景丽
春和景丽 2021-01-30 21:30

I am programming simple Windows apps. I don\'t need DB support. Why would I use WPF instead of WinForms?

相关标签:
7条回答
  • 2021-01-30 21:51

    A

    Anywhere Execution due to XAML.

    Can be used as WinApp, WebApp, Mobile.

    Whereas WindowsForm Internal UI representation is in C#.

    B

    Binding -->Simple object to object data transfer.

    C

    Common look and feel(Styles) -->can define look and feel styles commonly and use it for bunch of controls.

    D

    Directive Programming -->Binding objects in XAML.

    E

    Expression blend and Animation-->WPF uses DirectX, and DirectX can be used for animation.

    F

    Faster Execution(Hardware Rendering)

    WPF internally uses DirectX (Hardware rendering) while Winform internally uses GDI (mostly uses Software rendering).

    There are two ways by which a computer renders display on monitor.

    1) (CPU) Software rendering -->In case of CPU rendering ,the CPU drives the whole logic of rendering display on monitor.CPU also does other operations like running applications,performing memory management,running OS. So on top of it its extra load to display things on monitor.

    2)(GPU) Hardware rendering -->Its Specialized kinda processor, specifically meant for rendering and display faster on monitor.

    Now in WPF, this rendering is further optimised in

    >Tier 0 mode (Software rendering) uses DirectX7 internally,
    
    >Tier 1 mode (Partial Hardware rendering) uses DirectX7 to DirectX9 internally,
    
    >Tier 2 mode (Hardware rendering) uses DirectX9 internally. 
    

    G

    Graphic Independence (DIP) -->Means resolution independence

    Resolution --> Total number of pixels that fits into screen/monitor

    Pixel --> Simple dot on screen.

    Windows form uses pixels as a measurement unit, so when pixel changes then win forms has to adjust itself that means we have to write logic for it.

    But WPF does not use pixels as a measurement unit but uses DIP(Device independent pixels)

    1 DIP = 1/96th of the inch.

    At last Testing --> Better unit testing with use of MVVM pattern.

    0 讨论(0)
提交回复
热议问题