Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7941059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:33:09+00:00 2026-06-03T23:33:09+00:00

I cannot get a button style to work in a Prism 4.0 app with

  • 0

I cannot get a button style to work in a Prism 4.0 app with four modules. Here is the button element from the xaml view file in Module2:

<Button Name="add" Width ="60" Style="{DynamicResource Red}"  Click="add_Click"> Add</Button>

The app builds and runs but the button color does not appear. I have defined the style in the Generic.xaml file in the Themes folder of the Shell Module. That is supposed to be where one can place styles to be shared between the modules. In the Generic.xaml file I have:

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Shell.Controls" 
    xmlns:wc="clr-namespace:System.Windows.Controls;assembly=PresentationFramework">

 <Style 
   x:Key="{ComponentResourceKey 
    TypeInTargetAssembly={x:Type wc:Button},
    ResourceId=Red}"
    TargetType="wc:Button">
    <Setter Property="Foreground" Value="Red" />
  </Style>
</ResourceDictionary>

I also have the necessary reference in the AssemblyInfo.cs file in the Properties folder of the Shell Project. This should direct the Prism app to resolve all styles references from the Prism Generic.xaml file:

[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]

Those are still the original settings that were provided by the Prism WPF Unity template with which I started, provided by David Hill’s blog [http://blogs.msdn.com/b/dphill/archive/2011/01/16/prism-4-0-template-pack-now-available.aspx]. The template came with some styles already in Generic.xaml but the bare template app only used those styles for controls in the Shell assembly, hence the parameters, “None” and “SourceAssembly” shown above.

Since I am trying to define styles for use in modules other than the Shell module, I added the following ThemeInfo attribute to the AssemblyInfo.cs of Module1 and Module2L

[`assembly: ThemeInfo(ResourceDictionaryLocation.ExternalAssembly, ResourceDictionaryLocation.ExternalAssembly)]`

I Tried adding a ThemeDictionary extension to App.xaml like this in App.xaml & no result.

    <Application.Resources>
    <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="{ThemeDictionary MyApp}"/>
    </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
    </Application.Resources>

Also tried a pack url like this in App.xaml & got “Cannot locate resource” error.

    <Application.Resources>
    <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="pack://application:,,,/MyApp;Shell/Themes/Generic.xaml"/>
    </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
    </Application.Resources>

Any thoughts or ideas as to what is missing? Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:33:10+00:00Added an answer on June 3, 2026 at 11:33 pm

    UPDATE: I got the answer from Marc Rodman at Microsoft through technical support. Two changes:

    One was in Generic.xaml, changing the style definition to:

        <Style
    x:Key="Red"
    TargetType="Button">
        <Setter Property="Foreground" Value="Red" />
        </Style>
    

    The other change was to App.xaml:

      <Application.Resources>
    
        <ResourceDictionary
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <ResourceDictionary.MergedDictionaries>
         <ResourceDictionary
    Source="pack://application:,,,/Shell;component/Themes/Generic.xaml"/>
         </ResourceDictionary.MergedDictionaries>
         </ResourceDictionary>
        </Application.Resources>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using asp.net and cannot get the AddThis Facebook Send button work. They claim
My text is currently sitting below my button and I cannot get it centered
I cannot get the returning data from the server to display on my form
I cannot get a two-way bind in WPF to work. I have a string
I cannot get the internet explorer web developer tool bar to work with a
I cannot get Bindable LINQ to work with VB.NET for the life of me.
I have Buttons attached to elements on the modules entrypoint html page using RootPanel.get(foo).add(button)
As the title says, I cannot get padding around the text. Here's my xml:
I cannot get to the run and stop buttons outside of full screen mode
Cannot get this statement to update the table and am almost certain my problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.