Presenting PresentationHost
I always prefer simpler solutions. The solution I proposed on my previous post was not that simple, and was not complete. It may still be useful for other stuff, but for the purpose of preserving ClearType while using DWM, I just have to admit it has too many issues.
The idea of using another window stayed in my head, and then I realized I could use a child window. WPF already has a mechanism for hosting Windows Forms and ActiveX controls. They derive from HwndHost,which allows creating a window handle and embedding it within the WPF visual tree.
My control, PresentationHost, does just that. It hosts an HwndSource, which provides the infrastructure of WPF windows. You give the HwndSource a root visual to display, and since it is a separate window within the main window, whose composition background remains opaque, ClearType works just fine. You don’t have to modify anything in the Ribbon. Even routed commands work transparently!
The one downside I can think of is that everything inside the host is not part of the visual tree of the window. I did make sure it’s a part of the logical tree, so there’s a way to get into elements inside the host. XAML name references also work as usual.
Again, to compile/run the sample, you’ll have to obtain the Ribbon assembly separately from the Office UI Licensing site.
Attachment: PresentationHostDemo.zip
2 Responses to Presenting PresentationHost
Tags
.NET 4 Animation AppFabric Async Axum Blog C# ClearType Cloud CLR CodeValue Contests Deep Zoom Experiments Generics Google Ink Lectures Modeling Performance Personal Pivot Prism Programming Languages Prolog Reflector RTL Sela Silverlight The Arbel Network Themes Threading Tips Visual Studio WCF Windows 7 Windows 2003 Windows Azure Windows Forms Windows Phone Windows Vista Windows XP WPF XAML ZuneArchives
- May 2013
- February 2013
- June 2012
- May 2012
- June 2011
- November 2010
- August 2010
- July 2010
- June 2010
- March 2010
- December 2009
- November 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- November 2007
- September 2007
- June 2007
- May 2007
- February 2007
- November 2006
- October 2006
- February 2006
- August 2005
- February 2005
- August 2004
- July 2004
- June 2004
- May 2004






I can not compile. What is RibbonControlsLibray?
You need the Ribbon assembly. Look at the last paragraph for a link.