Euthyphro
Euthyphro

Reputation: 710

The attachable property "ThemeDictionaries" was not found in type "ResourceDictionary"

The following code is within app.xaml on a Windows Phone 8 application. It receives the error The attachable property "ThemeDictionaries" was not found in type "ResourceDictionary". Likewise, it does not set the background. I'm trying to set the background across the entire application with the option to change it using (App.Current.Resources["BackgroundImage"] as ImageBrush).ImageSource = imgSrc; through c# code.

<Application
    x:Class="MyApp.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone">  
     <Application.Resources>
          <ResourceDictionary>
           <ResourceDictionary.ThemeDictionaries>
              <ResourceDictionary x:Key="Default">
                    <ImageBrush x:Key="BackgroundImage" ImageSource="Assets/BackgroundDefault.jpg" Stretch="UniformToFill" />
              </ResourceDictionary>
              <ResourceDictionary x:Key="Dark">
                    <ImageBrush x:Key="BackgroundImage" ImageSource="Assets/BackgroundDark.jpg" Stretch="UniformToFill" />
              </ResourceDictionary>
           </ResourceDictionary.ThemeDictionaries>
            <local:LocalizedStrings xmlns:local="clr-namespace:MyApp" x:Key="LocalizedStrings"/>
            <DataTemplate x:Key="SmallPanoramaTitle">
                <ContentPresenter>
                    <TextBlock Text="{Binding}" FontSize="25" Margin="0,30,0,0" />
                </ContentPresenter>
            </DataTemplate>
        </ResourceDictionary>
      </Application.Resources>
      <Application.ApplicationLifetimeObjects>
        <!--Required object that handles lifetime events for the application-->
        <shell:PhoneApplicationService
            Launching="Application_Launching" Closing="Application_Closing"
            Activated="Application_Activated" Deactivated="Application_Deactivated"/>
       </Application.ApplicationLifetimeObjects>
</Application>

Upvotes: 0

Views: 834

Answers (1)

Null Pointer
Null Pointer

Reputation: 9309

ResourceDictionary.ThemeDictionaries not available in windows phone silverlight applications.

You can use the ThemeManager library to mange your themes in WP silverlight. This is an excellent library and its available in nuget also.

See this page to understand how to use ThemeManager . You can also load custom theme files

Upvotes: 1

Related Questions