{"id":436,"date":"2013-03-16T20:46:19","date_gmt":"2013-03-16T09:46:19","guid":{"rendered":"http:\/\/blog.quppa.net\/?p=436"},"modified":"2013-03-16T20:46:19","modified_gmt":"2013-03-16T09:46:19","slug":"wpf-tooltip-drop-shadows-in-windows-8","status":"publish","type":"post","link":"https:\/\/www.quppa.net\/blog\/2013\/03\/16\/wpf-tooltip-drop-shadows-in-windows-8\/","title":{"rendered":"WPF ToolTip Drop Shadows in Windows 8"},"content":{"rendered":"<p>The standard <a title=\"MSDN: ToolTip Class\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.windows.controls.tooltip.aspx\">ToolTip<\/a> control template for the Windows 8 theme in WPF (\u2018Aero2\u2019) has no drop shadow, whether or not the HasDropShadow property is set. The background colour and margins are also slightly off compared to the native style.<\/p>\n<p>The following template produces a result that\u2019s closer to the real thing:<\/p>\n<pre class=\"lang:xaml decode:true\">&lt;Style TargetType=&quot;{x:Type ToolTip}&quot;&gt;\n  &lt;Setter Property=&quot;Foreground&quot; Value=&quot;#FF575757&quot; \/&gt;\n  &lt;Setter Property=&quot;Background&quot; Value=&quot;#FFFFFFFF&quot; \/&gt;\n  &lt;Setter Property=&quot;Padding&quot; Value=&quot;5,1,6,2&quot; \/&gt;\n  &lt;Setter Property=&quot;HasDropShadow&quot; Value=&quot;{DynamicResource {x:Static SystemParameters.DropShadowKey}}&quot; \/&gt;\n  &lt;Setter Property=&quot;Template&quot;&gt;\n    &lt;Setter.Value&gt;\n      &lt;ControlTemplate TargetType=&quot;{x:Type ToolTip}&quot; xmlns:themes=&quot;clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero&quot;&gt;\n        &lt;themes:SystemDropShadowChrome Name=&quot;Shdw&quot; themes:SystemDropShadowChrome.Color=&quot;Transparent&quot; themes:SystemDropShadowChrome.CornerRadius=&quot;0&quot; SnapsToDevicePixels=&quot;True&quot;&gt;\n          &lt;Border Name=&quot;Border&quot; Background=&quot;{TemplateBinding Background}&quot; BorderBrush=&quot;{TemplateBinding BorderBrush}&quot; BorderThickness=&quot;{TemplateBinding BorderThickness}&quot; SnapsToDevicePixels=&quot;True&quot;&gt;\n            &lt;ContentPresenter TextOptions.TextFormattingMode=&quot;Display&quot; Margin=&quot;{TemplateBinding Padding}&quot; HorizontalAlignment=&quot;{TemplateBinding HorizontalContentAlignment}&quot; VerticalAlignment=&quot;{TemplateBinding VerticalContentAlignment}&quot; \/&gt;\n          &lt;\/Border&gt;\n        &lt;\/themes:SystemDropShadowChrome&gt;\n        &lt;ControlTemplate.Triggers&gt;\n          &lt;Trigger Property=&quot;HasDropShadow&quot; Value=&quot;True&quot;&gt;\n            &lt;Setter TargetName=&quot;Shdw&quot; Property=&quot;Margin&quot; Value=&quot;0,0,5,5&quot; \/&gt;\n            &lt;Setter TargetName=&quot;Shdw&quot; Property=&quot;themes:SystemDropShadowChrome.Color&quot; Value=&quot;#71000000&quot; \/&gt;\n          &lt;\/Trigger&gt;\n        &lt;\/ControlTemplate.Triggers&gt;\n      &lt;\/ControlTemplate&gt;\n    &lt;\/Setter.Value&gt;\n  &lt;\/Setter&gt;\n&lt;\/Style&gt;<\/pre>\n<p>You\u2019ll need to add a reference to PresentationFramework.Aero in your project (note the \u2018themes\u2019 namespace used in the control template).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Windows 8 Tooltips\" style=\"margin: 5px; border: 0px currentcolor; display: inline; background-image: none;\" border=\"0\" alt=\"Screenshot of Windows 8 Tooltips\" src=\"https:\/\/www.quppa.net\/blog\/wp-content\/uploads\/transparent.png\" width=\"50\" height=\"100\" \/><\/p>\n<p>The top image shows a standard Windows 8 tooltip, the middle shows the default tooltip appearance for WPF applications running in Windows 8, and the bottom shows a WPF tooltip using the above template. Note that the Win32 and WPF drop shadows are slightly different in appearance. Additionally, the WPF shadow fades in and out with the tooltip, while the Win32 shadow just pops in and out.<\/p>\n<p>Now, you\u2019ll only want to use this template when the user is running Windows 8, and if the user changes themes you\u2019ll no longer have tooltips that match the native style.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The standard ToolTip control template for the Windows 8 theme in WPF (\u2018Aero2\u2019) has no drop shadow, whether or not the HasDropShadow property is set. The background colour and margins are also slightly off compared to the native style. The following template produces a result that\u2019s closer to the real thing: &lt;Style TargetType=&quot;{x:Type ToolTip}&quot;&gt; &lt;Setter &hellip; <a href=\"https:\/\/www.quppa.net\/blog\/2013\/03\/16\/wpf-tooltip-drop-shadows-in-windows-8\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;WPF ToolTip Drop Shadows in Windows 8&#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":[142,148,152,171,185],"class_list":["post-436","post","type-post","status-publish","format-standard","hentry","category-programming","category-windows","tag-style","tag-themes","tag-tooltip","tag-windows-2","tag-wpf"],"_links":{"self":[{"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/posts\/436","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=436"}],"version-history":[{"count":0,"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/posts\/436\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/media?parent=436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/categories?post=436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/tags?post=436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}