Use StaticResources in Class Library on Windows 8.1

1.8k views Asked by At

I want to create a class library for my Windows 8.1 project, which includes all the views for my app. So I've created the project, but Visual Studio told me that it is not possible to access the StaticResources.

<StackPanel>
    <TextBlock 
        Text="123" 
        Style="{StaticResource HeaderTextBlockStyle}" />
    <TextBlock" 
        Text="456" 
        Style="{StaticResource HeaderTextBlockStyle}" />
</StackPanel>

For example 'HeaderTextBlockStyle' was marked in blue and it told me that the resource 'HeaderTextBlockStyle' could not be found. So I can't see my page in the designer, because of the issue.

I can run my app without problems, but how can I get access to the StaticResources?

1

There are 1 answers

0
murki On

In Windows 8.1 some things have changed, including the inclusion of the StandarStyles.xaml (it's no longer included explicitly). This guide is very helpful to make the transition: http://blogs.windows.com/windows/b/appbuilder/archive/2013/07/24/windows-8-to-windows-8-1-preview-starting-with-the-xaml-templates.aspx

For your specific problem I recommend you to try:

Style="{ThemeResource HeaderTextBlockStyle}"