{"id":2784,"date":"2015-01-13T22:35:00","date_gmt":"2015-01-13T22:35:00","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=2784"},"modified":"2015-01-13T22:35:00","modified_gmt":"2015-01-13T22:35:00","slug":"have-you-seen-the-bulletdecorator","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/have-you-seen-the-bulletdecorator\/","title":{"rendered":"Have you seen the BulletDecorator ?"},"content":{"rendered":"<p>So I was working on a fancy-ish tooltip (see my previous post). I wanted it to display a bold header and other information in a bullet point fashion underneath. Whilst researching how to do this I came across the BulletDecorator. <\/p>\n<p>There&#8217;s so much in WPF, I&#8217;m always finding new things or just different ways to do the same thing. This doesn&#8217;t really (from what I can see) do anything fantastically clever or the likes, but it&#8217;s sort of nice and descriptive in the XAML as to the intent.<\/p>\n<p>So to use the decorator we wrap the control we want to act as the bullet in the Bullet property and the content as a child of the control thus<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;BulletDecorator&gt;\r\n   &lt;BulletDecorator.Bullet&gt;\r\n      &lt;Ellipse Height=&quot;5&quot; Width=&quot;5&quot; Fill=&quot;Blue&quot;\/&gt;\r\n   &lt;\/BulletDecorator.Bullet&gt;\r\n   &lt;TextBlock Text=&quot;Item1&quot; Margin=&quot;3,0,0,0&quot;\/&gt;\r\n&lt;\/BulletDecorator&gt;\r\n<\/pre>\n<p>Now it&#8217;s most likely if you have one bullet point you&#8217;ll want several. So an easy way to apply the &#8220;style&#8221; is as follows.<\/p>\n<p>Create a ControlTemplate in the Resources section of your control (or wherever) that looks something like this<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;ControlTemplate x:Key=&quot;BulletTemplate&quot; TargetType=&quot;{x:Type ContentControl}&quot;&gt;\r\n   &lt;BulletDecorator&gt;\r\n      &lt;BulletDecorator.Bullet&gt;\r\n         &lt;Ellipse Height=&quot;5&quot; Width=&quot;5&quot; Fill=&quot;Blue&quot;\/&gt;\r\n      &lt;\/BulletDecorator.Bullet&gt;\r\n      &lt;ContentPresenter Margin=&quot;3,0,0,0&quot;\/&gt;\r\n   &lt;\/BulletDecorator&gt;\r\n&lt;\/ControlTemplate&gt;\r\n<\/pre>\n<p>Now in your XAML write this instead of the original code<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;ContentControl Template=&quot;{StaticResource BulletTemplate}&quot;&gt;\r\n   &lt;TextBlock Text=&quot;Item1&quot; \/&gt;\r\n&lt;\/ContentControl&gt;\r\n<\/pre>\n<p><strong>References<\/strong><\/p>\n<p><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.windows.controls.primitives.bulletdecorator%28v=vs.110%29.aspx\" title=\"BulletDecorator Class\" target=\"_blank\">BulletDecorator Class<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>So I was working on a fancy-ish tooltip (see my previous post). I wanted it to display a bold header and other information in a bullet point fashion underneath. Whilst researching how to do this I came across the BulletDecorator. There&#8217;s so much in WPF, I&#8217;m always finding new things or just different ways to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[13],"tags":[],"class_list":["post-2784","post","type-post","status-publish","format-standard","hentry","category-wpf"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/2784","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=2784"}],"version-history":[{"count":4,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/2784\/revisions"}],"predecessor-version":[{"id":2791,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/2784\/revisions\/2791"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=2784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=2784"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=2784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}