{"id":437,"date":"2013-03-16T20:52:43","date_gmt":"2013-03-16T09:52:43","guid":{"rendered":"http:\/\/blog.quppa.net\/?p=437"},"modified":"2013-03-16T20:52:43","modified_gmt":"2013-03-16T09:52:43","slug":"native-tooltips-in-wpf-part-1","status":"publish","type":"post","link":"https:\/\/www.quppa.net\/blog\/2013\/03\/16\/native-tooltips-in-wpf-part-1\/","title":{"rendered":"Native Tooltips in WPF (Part 1)"},"content":{"rendered":"<blockquote><p><a href=\"https:\/\/github.com\/Quppa\/NativeToolTipsWPF\" title=\"GitHub: NativeToolTipsWPF\">View source on GitHub.<\/a><\/p><\/blockquote>\n<p>&lt;preamble&gt;<\/p>\n<p>One of my hobbies is getting WPF controls to look more like their native counterparts. I\u2019ve been shoehorning the UxTheme APIs (and older equivalents when theming is unavailable) into something that can be used by WPF over the past year or more, and I\u2019ll write about this process at some point in the future (I\u2019ve implemented native-looking push buttons, radio buttons, checkboxes, scrollbars, list views\/list view items, text boxes, group boxes and read-only combo boxes). These efforts pay off the most in Windows 8, since WPF\u2019s theme for that OS leaves much to be desired (just look at the push buttons!). This isn\u2019t entirely surprising given that the theme wasn\u2019t finalised until post-RC, leaving the WPF team without much time to do a good job.<\/p>\n<p>&lt;\/preamble&gt;<\/p>\n<p>In this post I\u2019ll compare WPF tooltips with Win32 tooltips, and in part 2 I\u2019ll demonstrate how to use Win32 tooltips in a WPF application and post some sample code.<\/p>\n<p>Tooltips in WPF look more or less like traditional Windows tooltip controls. Here are some advantages and disadvantages of each:<\/p>\n<p><strong>WPF Tooltips<\/strong><\/p>\n<p>Advantages:<\/p>\n<ul>\n<li>Can host any content, not just text.<\/li>\n<li>Style them like any WPF control.<\/li>\n<li>Drop shadow fades in and out.<\/li>\n<\/ul>\n<p>Disadvantages:<\/p>\n<ul>\n<li>Colours aren\u2019t quite the same as native tooltips.<\/li>\n<li>Weird bottom margin\/padding with Aero theme.<\/li>\n<li>Drop shadows don\u2019t look exactly like Win32 tooltip shadows.<\/li>\n<li>Drop shadows are missing in the Windows 8 theme, regardless of system settings (can be fixed by <a title=\"WPF ToolTip Drop Shadows in Windows 8\" href=\"https:\/\/www.quppa.net\/blog\/2013\/03\/16\/wpf-tooltip-drop-shadows-in-windows-8\/\">modifying the control template<\/a>, which is missing SystemDropShadowChrome, meaning the \u2018HasDropShadow\u2019 property does nothing).<\/li>\n<li>No ClearType without <a title=\"New WPF Features: ClearTypeHint\" href=\"http:\/\/blogs.msdn.com\/b\/llobo\/archive\/2009\/10\/28\/new-wpf-features-cleartypehint.aspx\">RenderOptions.ClearTypeHint<\/a>.<\/li>\n<\/ul>\n<p><strong>Win32 Tooltips<\/strong><\/p>\n<p>Advantages:<\/p>\n<ul>\n<li>Consistent with tooltips in native applications.<\/li>\n<\/ul>\n<p>Disadvantages:<\/p>\n<ul>\n<li>Can only display text (displaying other things is <a title=\"InteractiveToolTip - Tooltips you can click on!\" href=\"http:\/\/www.codeproject.com\/Articles\/529753\/InteractiveToolTip-Tooltips-you-can-click-on\">non-trivial<\/a>).<\/li>\n<li>Can\u2019t be styled.<\/li>\n<li>Drop shadows don\u2019t fade in or out.<\/li>\n<li>Animations sometimes don\u2019t fire (particularly the fade-in animation).<\/li>\n<li>Updating the text of an open tooltip can cause redraw flicker.<\/li>\n<li>Custom positioning can involve a lot of work.<\/li>\n<\/ul>\n<p>There are some other very minor differences:<\/p>\n<ul>\n<li>The algorithm for finding the position under the mouse is different in WPF, even though it\u2019s based on the \u2018_GetHcursorPdy3\u2019 function from tooltips.cpp, according to the reference source.<\/li>\n<li>When the content of a native tooltip changes, the tooltip will be repositioned beneath the cursor. WPF tooltips remain fixed in place.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>View source on GitHub. &lt;preamble&gt; One of my hobbies is getting WPF controls to look more like their native counterparts. I\u2019ve been shoehorning the UxTheme APIs (and older equivalents when theming is unavailable) into something that can be used by WPF over the past year or more, and I\u2019ll write about this process at some &hellip; <a href=\"https:\/\/www.quppa.net\/blog\/2013\/03\/16\/native-tooltips-in-wpf-part-1\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Native Tooltips in WPF (Part 1)&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,9],"tags":[148,152,160,185],"class_list":["post-437","post","type-post","status-publish","format-standard","hentry","category-programming","category-windows","tag-themes","tag-tooltip","tag-uxtheme","tag-wpf"],"_links":{"self":[{"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/posts\/437","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/comments?post=437"}],"version-history":[{"count":0,"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/posts\/437\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/media?parent=437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/categories?post=437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/tags?post=437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}