最终使用没有实际窗口的HwndHost。
void cwind()
{
Application myapp = new Application();
mrenderer = new WPFRenderer();
mrenderer.Width = 256;
mrenderer.Height = 256;
HwndSourceParameters myparms = new HwndSourceParameters();
HwndSource msrc = new HwndSource(myparms);
myparms.HwndSourceHook = new HwndSourceHook(ApplicationMessageFilter);
msrc.RootVisual = mrenderer;
myapp.Run();
}
static IntPtr ApplicationMessageFilter(
IntPtr hwnd, int message, IntPtr wParam, IntPtr lParam, ref bool handled)
{
return IntPtr.Zero;
}