{"id":4642,"date":"2014-03-30T14:14:36","date_gmt":"2014-03-30T14:14:36","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/wpf-ribbonbutton-collection-of-common-programming-errors\/"},"modified":"2014-03-30T14:14:36","modified_gmt":"2014-03-30T14:14:36","slug":"wpf-ribbonbutton-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/wpf-ribbonbutton-collection-of-common-programming-errors\/","title":{"rendered":"WPF RibbonButton-Collection of common programming errors"},"content":{"rendered":"<p>RibbonButtons from the RibbonControlsLibrary behave differently than standard WPF buttons and need a command to display text. The command is where you also assign the images and other items such as tool tips.<\/p>\n<pre><code>var cmd = new RibbonCommand();\ncmd.LabelTitle = \"Browse\";\ncmd.CanExecute += ( sender, args ) =&gt; args.CanExecute = true;\ncmd.Executed +=new ExecutedRoutedEventHandler(cmd_Executed);\n\nvar btn = new RibbonButton();\nbtn.Command = cmd;\n\nMyRibbonGroup.Controls.Add( btn );\n<\/code><\/pre>\n<p>You must assign true to CanExecute, otherwise will the command\/button will always be disabled. The CanExecute method can have your business logic disable or enable the command\/button as well.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>RibbonButtons from the RibbonControlsLibrary behave differently than standard WPF buttons and need a command to display text. The command is where you also assign the images and other items such as tool tips. var cmd = new RibbonCommand(); cmd.LabelTitle = &#8220;Browse&#8221;; cmd.CanExecute += ( sender, args ) =&gt; args.CanExecute = true; cmd.Executed +=new ExecutedRoutedEventHandler(cmd_Executed); var [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4642","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4642","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4642"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4642\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}