0
votes

I am developing a windows phone 8.1 (silverlight) app and I need to change background color according to phone's theme. One way that I found is

Background="{StaticResource PhoneAccentBrush}"

But it is required to restart the app when theme is changed. I want to reflect without restarting app.

I went through JAYWAY Windows Phone 8.1 for Developers – Theme resources and found

Background="{ThemeResource SystemColorControlAccentColor}"

When I inserted this line in my page, Visual Studio shows me following errors

  1. The name "ThemeResource" does not exist in the namespace "http://schemas.microsoft.com/client/2007"
  2. The type 'ThemeResource' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

So, is it any way to use ThemeResource in windows phone 8.1 silverlight or any equivalent to ThemeResource?

P.S.: I am using Visual Studio 2013 Professional.

1

1 Answers

1
votes

As you noticed, ThemeResource is available only for WinRT. Unfortunately there is no reliable way to dynamically update a resource in Silverlight, that's why pretty much every application with multiple themes require the user to restart. Even if you were to somehow mimic ThemeResource using a custom markup extension or a converter, you wouldn't be able to apply it to built-in/third-party controls without re-templating all of them.