在Windows 8.1上的类库中使用StaticResources

时间:2013-12-09 10:36:30

标签: windows winrt-xaml staticresource

我想为我的Windows 8.1项目创建一个类库,其中包含我的应用程序的所有视图。所以我创建了这个项目,但Visual Studio告诉我无法访问StaticResources。

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

例如,'HeaderTextBlockStyle'标记为蓝色,它告诉我无法找到资源'HeaderTextBlockStyle'。因此,我无法在设计师中看到我的页面。

我可以毫无问题地运行我的应用程序,但是如何才能访问StaticResources?

1 个答案:

答案 0 :(得分:0)

在Windows 8.1中,一些事情发生了变化,包括包含StandarStyles.xaml(不再明确包含它)。本指南对转换非常有帮助:http://blogs.windows.com/windows/b/appbuilder/archive/2013/07/24/windows-8-to-windows-8-1-preview-starting-with-the-xaml-templates.aspx

针对您的具体问题,我建议您尝试:

Style="{ThemeResource HeaderTextBlockStyle}"