Question on applying Style from a Resource Directory RRS feed

  • Question

  • Given:

    This is the project Folder Heirarchy:

    • Root Folder
      • App.Xaml
      • Window1.Xaml
      • Style Folder
        • ExpressionDark.Xaml
        • MergedDicts.xaml
        • Other styles
      • Windows Folder
        • Window2.xaml

    App.Xaml has this content:

    <Application.Resources> <ResourceDictionary Source="Style/MergedDicts.xaml"></ResourceDictionary> </Application.Resources>

    MergedDictionaries has this:

    <ResourceDictionary xmlns="" xmlns:x=""> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="ExpressionDark.xaml"></ResourceDictionary> (Other styles follow here but unimportant to problem....) </ResourceDictionary.MergedDictionaries> </ResourceDictionary>


    Window 1 in the root folder finds the ExpressionDark Style no problem, but Window 2 in the "Windows" folder does not... How does one point to a style for a Window not picking up the App.Xaml directions? And shouldn't the App.Xaml have been sufficient for this?

    Friday, June 11, 2010 2:13 PM


All replies

  • Instead of using short path in MergeDictionary use the full qualified path like below which might be helpfull in your case.

    <Application.Resources> <ResourceDictionary Source=""/YourApplicationName;component/Style/MergedDicts.xaml"></ResourceDictionary> </Application.Resources>

    Also try to use full path for ExpressionDark.xaml


    Nayan Paregi (MCTS)
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Friday, June 11, 2010 5:35 PM
  • Hi Mr.Javaman,

    What is the platform you use? There is a known issue about ResourceDictionary.MergedDictionaries if you use Visual Studio 2010. Please refer to this blog about this issue: 

    There is a workaround for this issue, declare an empty style for an element in MergedDicts.xaml:

      <ResourceDictionary Source="ExpressionDark.xaml">
       <Style TargetType="Window"/>

    The similar thread:


    Bob Bao

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Tuesday, June 15, 2010 5:58 AM
  • Use by this way it would not be a problem now ,



    <ResourceDictionary Source="Style Folder\ExpressionDark.xaml"/>

    Tuesday, June 15, 2010 6:45 AM