Category: WPF
Posted by: Mike
Although the WindowsFormsIntegration dll provides some functionality to provide interop between winforms and WPF, there are some other possibilities. ElementHost allows you to host WPF elements in your winform app and WindowsFormsHost allows you to host winform controls in your WPF application. But what if you would like to add a complete form to your winform app? What I did was to write a WPFRuntime class which helps you to display WPF windows from within a windows application. The class starts a new thread that runs the WPF application runtime with the help of a hidden window. Then you have some methods that ask the WPF application dispatcher to show a window of the type you provided. This allows you to create new windows entirely in WPF and still host them in a legacy winform application. The class might need some extensions to provide parameters to a window for instance but that is for a later time perhaps. You can find the demo code here
Category: WPF
Posted by: Mike
When you use blend on a HP computer, it could happen that your designer can't show any XAML files. You always get an error like 'The name "..." does not exist in the namespace
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"'. After searching for quite a while I discovered this was due to an environment variable. Some HP systems set a PLATFORM environment variable to e.g. MCD or HP. This causes MSBuild (and for that matter also blend and Visual Studio) to use that platform as the target platform in stead of 'Any CPU'. Remove the environment variable and the problem should be resolved.