views:

155

answers:

3

Does it perform drawing by itself, or uses the native UI components provided by Windows in any way?

A: 

It uses DirectX 9 to perform all its drawing. It doesn't use WinForms controls

jeffora
Can you provide a citation to support the fact that WPF uses DirectX9 to render?
Stewart
He can not - because this is as wrong as it gets ;) Hehe. It uses actually DIrectX 10 IIRC if available. See my answer.
TomTom
http://msdn.microsoft.com/en-us/library/ms750441.aspx discusses the internals. The specific version I'm sure is documented somewhere, but it was more from my own experience trying to use WPF as a UI overlay in games. It uses DirectX 9. Specifically, on Vista and Win7, IDirect3DDevice9Ex and on XP IDirect3DDevice9. Check the loaded modules for any WPF process. No d3d10.dll will be present.
jeffora
Jeremiah Morril sort of discusses it when looking into interop between XNA and WPF http://jmorrill.hjtcentral.com/Home/tabid/428/EntryId/259/XNA-Meet-WPF.aspx.
jeffora
+2  A: 

In WPF you can skin all of the controls in whatever way you please by overriding the templates. You absolutely can't do this with win32 controls, so therefore it can't use them.

Stewart
+3  A: 

WPF sort of uses native controls because WPF is the new native way to render controls in Windows - what you consider native is legacy win32, and basically slowly on the way to history.

MS did a lot of optimization in DirectX to allow WPF efficiently to render using the GPU. This is a new "native" interface that is also used to render the Vista upward AERO interface. WPF goes directly to a native layer that then does whatever it can in the GPU - including text rendering.

Now, the reall tricky part in your question is "native UI components provided by windows in ANY MEANS" - well, these low level functions are provided by Windows, so the answer is yes. Primitive drawing operations in a new API were added, but they were added specifically FOR WPF, which is now considered to be sort of the new "native windows presentation layer". MS is slowly moving away from the Win32 API towards WPF for generic presentations (Direct X etc. stays around - WPF is way too generic to be usable for example for high performance first person shooters). As such, given WPF is the new "native components layer", the question gets really tricky to answer ;)

TomTom
Great explanation! But by `native UI components' I meant exactly the legacy win32 controls, and not the GDI/DirectX/OpenGL routines which are used by WPF or Swing (Java); so that part of my question wasn't intended to be tricky. Anyway, your description of the mind shift about what is `native' now and what should considered `legacy' is quite helpful and refreshing)
Bubba88
I think some elements of your answer are somewhat misleading. It seems you have confused some of the developments within the Windows API (specifically Desktop Window Manager: http://msdn.microsoft.com/en-us/library/aa969540(VS.85).aspx) with the managed WPF framework. Some of those features you talk about (such as Aero) are not natively exposed through WPF, and to be included in a WPF app (or a WinForms) require calls to be made to the native Windows API. Also, WPF was never meant as a replacement for DirectX. It is a framework for developing desktop client applications built on DirectX (cont)
jeffora
DirectX has always been a highly optimised, high performance library, and this is necessary for games and similar applications to be able to squeeze the raw performance out of the hardware required for the sort of processing they are doing. Using a managed framework such as WPF actually significantly reduces the raw performance that can be achieved, but performance was not the goal of WPF.
jeffora
Actually I think performanc WAS the goal, but not in "the last drop" but "very good for the intended use". They did a lot of optimizations there for WPF 4. 3d games are just not the intended use ;) OTOH I do some application here doing a LOT of UI work (visualiting financial market data on X screens, possibly thousands of updates per second) and I like the performance optimizations they have done in 4.0 ;)
TomTom
I wasn't saying that WPF wasn't designed with performance in mind, but it wasn't designed as a replacement for high performance 3D engines and similar technologies. I was also not disputing that it was an optimised framework. But it's the WPF framework and internals that are changed between versions - all versions (including WPF 4) run internally using DirectX version 9.
jeffora