{"id":351,"date":"2013-02-26T09:55:00","date_gmt":"2013-02-26T09:55:00","guid":{"rendered":"https:\/\/staging.infragistics.com\/blogs\/?p=351"},"modified":"2025-02-26T12:29:47","modified_gmt":"2025-02-26T12:29:47","slug":"dark-theme-for-the-wpf-xamdatagrid","status":"publish","type":"post","link":"https:\/\/www.infragistics.com\/blogs\/dark-theme-for-the-wpf-xamdatagrid","title":{"rendered":"A Dark Theme for the WPF XamDataGrid"},"content":{"rendered":"\n<p>There has been quite a bit of interest in dark themes recently. This is because more users are finding the white background of applications straining their eyes, especially when they are spending a lot of time in front of the computer screen.<\/p>\n\n\n\n<p>The convenience of having a darker theme was also recognized by Microsoft in Visual Studio 2012, which comes with such a dark theme built-in. We have received a number of requests for dark themes for our <a href=\"\/products\/wpf\/\" target=\"_blank\" rel=\"noopener noreferrer\">NetAdvantage for WPF<\/a> controls, and until now, we could only advise on how customers could build such a dark theme by themselves. We\u2019ve now been able to build such a dark theme for select WPF controls and are happy to provide it freely.<\/p>\n\n\n\n<p>We decided to start the theming work with the most-often used Infragistics control in WPF line of business applications &#8211; the <a href=\"\/products\/wpf\/data-grid\/\" target=\"_blank\" rel=\"noopener noreferrer\">XamDataGrid<\/a> (a part of <a href=\"\/products\/wpf\/\" target=\"_blank\" rel=\"noopener noreferrer\">NetAdvantage for WPF<\/a>) &#8211; a high-performance, fully-featured, richly stylable control. This blogpost features a dark theme for the <a href=\"\/products\/wpf\/data-grid\/\" target=\"_blank\" rel=\"noopener noreferrer\">XamDataGrid<\/a> and editor controls, which can readily be extracted and used to produce a UI that\u2019s easy on the eyes.<\/p>\n\n\n\n<p>Please download the <a href=\"http:\/\/users.infragistics.com\/kmatev\/blogs\/MetroThemeDarkXamDataGrid.zip\" target=\"_blank\" rel=\"noopener noreferrer\">sample project<\/a> \u2013 it integrates the <a href=\"\/products\/wpf\/data-grid\/\" target=\"_blank\" rel=\"noopener noreferrer\">XamDataGrid<\/a> with a <a href=\"\/products\/wpf\/formula-editor\">XamFormulaEditor<\/a> and includes the dark theme for these two controls. <strong>Please remember to <a href=\"http:\/\/blogs.infragistics.com\/cfs-file.ashx\/__key\/CommunityServer.Blogs.Components.WeblogFiles\/kiril_5F00_matev.Tuning+the+XamDataChart+for+Blazing-Fast+Charting\/unblockZIP.jpg\">unblock the ZIP archive<\/a> before extracting it. <\/strong>The project is built using Visual Studio 2010 and .NET Framework 4. It uses the <a href=\"\/products\/wpf\/data-grid\/\" target=\"_blank\" rel=\"noopener noreferrer\">XamDataGrid<\/a> in the the 12.2 <a href=\"\/products\/wpf\/\" target=\"_blank\" rel=\"noopener noreferrer\">NetAdvantage for WPF<\/a> product, so you can build and run it without any additional downloads. <a href=\"\/downloads\/generate\/00000000-0000-0000-0000-000000005912\">Fully-functional free 30-day trial<\/a> of the <a href=\"\/products\/wpf\/\" target=\"_blank\" rel=\"noopener noreferrer\">NetAdvantage for WPF<\/a> product, which includes the <a href=\"\/products\/wpf\/data-grid\/\" target=\"_blank\" rel=\"noopener noreferrer\">XamDataGrid<\/a> is <a href=\"\/downloads\/generate\/00000000-0000-0000-0000-000000005912\">available<\/a>. Here\u2019s a screenshot of the <a href=\"\/products\/wpf\/data-grid\/\" target=\"_blank\" rel=\"noopener noreferrer\">XamDataGrid<\/a> themed in the dark theme:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"\/community\/cfs-file.ashx\/__key\/CommunityServer.Blogs.Components.WeblogFiles\/kiril_5F00_matev.metablogapi\/5811.image_5F00_2.png\"><img decoding=\"async\" src=\"http:\/\/static.infragistics.com\/marketing\/Blogs\/Migration\/kiril_matev\/metablogapi\/5811.image_2.png\" alt=\"A Dark Theme for the WPF XamDataGrid\" title=\"A Dark Theme for the WPF XamDataGrid\"\/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"how-to-access-the-theme\">How to Access the Theme<\/h2>\n\n\n\n<p>The <a href=\"\/products\/wpf\/data-grid\/\" target=\"_blank\" rel=\"noopener noreferrer\">XamDataGrid<\/a> Metro Dark theme is in DataPresenter_MetroDark.xaml and Editors_MetroDark.xaml files. As part of this, we\u2019re also making available dark styles for XamFormulaEditor &#8211; in DataTree_MetroDark.xaml and FormulaEditor_MetroDark.xaml. These contain both the control templates, and the brushes and colors used to style these controls.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"modifying-the-theme\">Modifying the Theme<\/h2>\n\n\n\n<p>You can modify the colors of the brushes directly in the DataPresenter_MetroDark.xaml and Editors_MetroDark.xaml. While this approach may work for a few brush settings, if you\u2019d like to change all the colors of the theme into a particular color hue, it\u2019s much easier to use a <a href=\"http:\/\/help.infragistics.com\/Doc\/WPF\/2012.2\/CLR4.0\/?page=InfragisticsWPF4.v12.2~Infragistics.Windows.Themes.ResourceWasher.html\">ResourceWasher<\/a>. Resource washing lets you change the colors of all brushes in the resource dictionary, thus giving you the capability to customize the visual appearance of a control, while keeping the relative shades of colors in different elements of the control. You can read more about how to use a <a href=\"http:\/\/help.infragistics.com\/Doc\/WPF\/2012.2\/CLR4.0\/?page=InfragisticsWPF4.v12.2~Infragistics.Windows.Themes.ResourceWasher.html\">ResourceWasher<\/a> <a href=\"http:\/\/help.infragistics.com\/Doc\/WPF\/2012.2\/CLR4.0\/?page=ResWash_Adding.html\">here<\/a>. This approach is illustrated in the sample.<\/p>\n\n\n\n<p>In the sample we\u2019re using a Transparent <a href=\"http:\/\/help.infragistics.com\/Doc\/WPF\/2012.2\/CLR4.0\/?page=InfragisticsWPF4.v12.2~Infragistics.Windows.Themes.WashGroup~WashColor.html\">WashColor<\/a> on the <a href=\"http:\/\/help.infragistics.com\/Doc\/WPF\/2012.2\/CLR4.0\/?page=InfragisticsWPF4.v12.2~Infragistics.Windows.Themes.ResourceWasher.html\">ResourceWasher<\/a> in the MainWindow in order to show the dark theme as it is defined in the styles. If you\u2019d like to activate the resource washing, please change the <a href=\"http:\/\/help.infragistics.com\/Doc\/WPF\/2012.2\/CLR4.0\/?page=InfragisticsWPF4.v12.2~Infragistics.Windows.Themes.WashGroup~WashColor.html\">WashColor<\/a> setting to a different color.<\/p>\n\n\n\n<p>In this case we\u2019re washing the entire theme in a single color. Resource washing has much greater capabilities and can wash different groups of brushes in different colors if your scenario demands it. This more advanced approach is presented <a href=\"http:\/\/help.infragistics.com\/Doc\/WPF\/2012.2\/CLR4.0\/?page=ResWash_Using.html\">here<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"summary\">Summary<\/h2>\n\n\n\n<p>Styling is ever more important in desktop applications, as desktop applications are competing with the interactivity and theming in mobile applications. In this blog post, we presented a dark theme for the <a href=\"\/products\/wpf\/data-grid\/\" target=\"_blank\" rel=\"noopener noreferrer\">XamDataGrid<\/a> and <a href=\"\/products\/wpf\/formula-editor\/\" target=\"_blank\" rel=\"noopener noreferrer\">XamFormulaEditor<\/a>, which lets you achieve a dark look for your application. You can use the these styles as they are, or you can easily use them as a base for resource washing, which will let you produce a variety of color combinations to suit your applications.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There has been quite a bit of interest in dark themes recently. This is because more users are finding the white background of applications straining their eyes, especially when they are spending a lot of time in front of the computer screen. <\/p>\n","protected":false},"author":94,"featured_media":2370,"comment_status":"publish","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-351","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to"],"_links":{"self":[{"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/posts\/351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/users\/94"}],"replies":[{"embeddable":true,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/comments?post=351"}],"version-history":[{"count":4,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/posts\/351\/revisions"}],"predecessor-version":[{"id":2529,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/posts\/351\/revisions\/2529"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/media\/2370"}],"wp:attachment":[{"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/media?parent=351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/categories?post=351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/tags?post=351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}