locked
StaticResource not working

    Question

  • An app gets many unhandled exceptions at runtime such as the following:

    Message = "Cannot find a Resource with the Name/Key TextStyleLargeFontSize [Line: 100 Position: 71]"

    The code corresponding to the above error is the following:

    <TextBlock Text="{Binding ResolutionSelected}" 
                VerticalAlignment="Center" FontSize="{StaticResource TextStyleLargeFontSize}"
                Margin="5"/>

    Again, there are other similar errors all of which are related to StaticResource. The app compiles fine.  I am wondering what the app is missing.

    This is a Win8.1 app developed with VS2013. The StaticResource values are selected among choices given by VS2013, not manually entered.  

     

    Hong

    Monday, March 23, 2015 4:33 AM

Answers

  • Hi Hong (MA, USA),

    I have tested in my side, it seems that this StaticResource TextStyleLargeFontSize is available in the Windows Phone 8.1 app, but it is not available in the Windows 8.1 app:

    >>The StaticResource values are selected among choices given by VS2013, not manually entered.  

    Could you please tell me how do you choose this StaticResource TextStyleLargeFontSize by using the Visual Studio 2013?

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Tuesday, March 24, 2015 7:43 AM
    Moderator

All replies

  • Can you post a full project to let me have a test?
    Tuesday, March 24, 2015 7:22 AM
  • Hi Hong (MA, USA),

    I have tested in my side, it seems that this StaticResource TextStyleLargeFontSize is available in the Windows Phone 8.1 app, but it is not available in the Windows 8.1 app:

    >>The StaticResource values are selected among choices given by VS2013, not manually entered.  

    Could you please tell me how do you choose this StaticResource TextStyleLargeFontSize by using the Visual Studio 2013?

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Tuesday, March 24, 2015 7:43 AM
    Moderator
  • Hello Amy,

    Thanks a lot for looking into this.  I have realized the question that I posted in a rush should have a bit more details:

    1. The Windows Phone project of the Universal Apps project works fine just as you found out.  Only the Windows 8.1 project has this problem.
    2. The XAML file is in the shared folder, not in Windows 8.1 project folder.

    To answer your question, I selected them through either the IntelliSense or the properties pane (i.e. the normal way, nothing special).   


    Hong

    Tuesday, March 24, 2015 11:46 AM
  • This property is not supported in Windows 8.1. You can not use it.
    Monday, March 30, 2015 1:56 AM
  • Thanks for confirming what Amy found out.

    I have been wondering if there is a way to show only choices available for both WP8.1 and W8.1 when editing a XAML file in the shared folder so that one does not have to switch between WP8.1 and W8.1 frequently to check whether a static resource can be used.


    Hong

    Monday, March 30, 2015 2:07 AM