{"id":22,"date":"2012-03-27T09:34:24","date_gmt":"2012-03-27T08:34:24","guid":{"rendered":"http:\/\/www.bjarneryd.se\/?p=22"},"modified":"2012-11-05T21:44:42","modified_gmt":"2012-11-05T20:44:42","slug":"change-theme-when-developing-a-metro-app","status":"publish","type":"post","link":"https:\/\/www.bjarneryd.se\/?p=22","title":{"rendered":"Change theme when developing a Metro app"},"content":{"rendered":"<p>When creating a Metro-app for Windows 8, you as a developer can choose to use a light or dark theme for the application. For those of you that have previously developed for Windows Phone 7, this is nothing new.<\/p>\n<p>The theme is predefined and when you are using Dark (which is default by the way), the background will be dark and text and so on will be set to light colors. When using the Light theme it is the other way around. You can of course customize everything.<\/p>\n<p>So how do you change from Dark to Light theme for the app?<br \/>\nHere follows one simple example of how to do this.<\/p>\n<p>First, locate your App.xaml-file in your solution. It will be in the root of your project. Open the code behind section and locate the constructor. Then add this line for light theme;<br \/>\nApp.Current.RequestedTheme = ApplicationTheme.Light;<br \/>\nor for dark theme use;<br \/>\nApp.Current.RequestedTheme = ApplicationTheme.Dark;<\/p>\n<p>The result should now look like:<br \/>\n[sourcecode language=&#8221;csharp&#8221;]<br \/>\npublic App()<br \/>\n{<br \/>\nthis.InitializeComponent();<br \/>\n\/\/The following line changes the theme for the application. Use ApplicationTheme.Dark for dark theme.<br \/>\nApp.Current.RequestedTheme = ApplicationTheme.Light;<br \/>\nthis.Suspending += OnSuspending;<br \/>\n}<br \/>\n[\/sourcecode]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When creating a Metro-app for Windows 8, you as a developer can choose to use a light or dark theme for the application. For those of you that have previously developed for Windows Phone 7, this is nothing new. The theme is predefined and when you are using Dark (which is default by the way), [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.bjarneryd.se\/index.php?rest_route=\/wp\/v2\/posts\/22"}],"collection":[{"href":"https:\/\/www.bjarneryd.se\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bjarneryd.se\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bjarneryd.se\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bjarneryd.se\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=22"}],"version-history":[{"count":6,"href":"https:\/\/www.bjarneryd.se\/index.php?rest_route=\/wp\/v2\/posts\/22\/revisions"}],"predecessor-version":[{"id":61,"href":"https:\/\/www.bjarneryd.se\/index.php?rest_route=\/wp\/v2\/posts\/22\/revisions\/61"}],"wp:attachment":[{"href":"https:\/\/www.bjarneryd.se\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=22"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bjarneryd.se\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=22"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bjarneryd.se\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=22"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}