Locked StaticResource reference was not found.

  • Wednesday, December 31, 2008 10:54 PM
     
     
    The designer gives me a "StaticResource reference was not found." error for references to application resources, if my App.xaml is in a subdirectory under the project. Even though the designer complains, the code builds and runs fine.

    For example in a brand new WPF Application project:

    In App.xaml:

    <Application.Resources>
        <Style x:Key="RedLabel" TargetType="{x:Type Label}">
            <Setter Property="Foreground" Value="Red"/>
        </Style>
    </Application.Resources>

    In Window1.xaml

    <Label Style="{StaticResource RedLabel}" Content="Test Label"/>


    At this point the designer is happy to display Window1.xaml. But then I add the folder src under my WpfApplication1 and move App.xaml and Window1.xaml into it.

    When I attempt to view Window1.xaml I get the error "StaticResource reference 'RedLabel' was not found.". The code however compiles and runs as expected.


        - David

All Replies

  • Friday, January 02, 2009 8:27 AM
     
     Proposed
    Hi, David,

    Thanks for reporting this issue. I can confirm that WPF designer has issue finding resources defined within application definition file (app.xaml) if app.xaml is not on the root directory of the project. This issue is being tracked as a product bug.

    The current workaround is not to change the location of app.xaml.

    Thanks again, and Happy New Year of 2009.

    Zhanbo
    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Proposed As Answer by Atul Gupta Friday, January 09, 2009 12:36 PM
    •  
  • Friday, June 17, 2011 10:28 AM
     
     

    Is this still not fixed???

    The moment I created my own startup.cs and added the main entry point, this happened.. which really sucks because I cannot see at design time my UI layout.