It seems like WPF was created as the application answer to Adobe's Flash. Silverlight is used for creating web pages. But, can that same functionality be pulled into a standalone WPF application. Scaleform allows Flash to be used within unmanaged C++ games. Can WPF be used to create the same type of interfaces? What I've read seems to make me believe it can. But, I haven't seen any screenshots of applications that show this kind of interface.
views:
62answers:
2Yes. There's no reason why it couldn't. You'd just have to do your work to create and apply styles that make it look like whatever you want.
It is work, but it isn't magic.
Absolutely! WPF can do everything Flash can do in building game UIs and much, much, much more.
WPF appliations can run several ways:
- As a standalone application using pure managed code
- As a standalone application using both managed and native code (including C++ code and UI)
- As a web application running within the browser using ClickOnce (this is known as XBAP)
(Silverlight is a subset of WPF that can run as a standalone application or in the browser, but cannot include native code)
THe really cool thing about WPF is that, unlike Flash, it can directly and seamlessly incorporate C++ code and DirectX/OpenGL UI elements. It can also directly call the code and share data structures with unmanaged C++ code. With Flash this requires a specialized runtime such as Scaleform and is not entirely compatible. In addition, the connection to unmanaged code is not as clean.
Because the capability to integrate with unmanaged code and UI is built directly into WPF, there is no need for an external vendor such as Scaleform to build anything. So nobody is collecting screen shots of games with a WPF-based UI environment because nobody is trying to sell anything.
Here is how it is usually done:
<Window ...>
<Grid>
<WindowsFormsHost x:Name="host"/> <!-- Unmanaged code will be child of this hWnd -->
<Grid>
<!-- WPF UI elements here -->
</Grid>
</Grid>
</Window>
with code:
InitializeUnmanagedUI(host.Handle);
That's pretty much all there is to it.
As far as data goes, the managed and unmanaged components can easily use each other's objects: The unmanaged code can use the managed objects through IJW and C++/CLR. The managed code can use and bind the unmanaged objects through COM.