PhoneApplicationPage 无法解析 StaticResource

发布于 2025-01-03 19:57:47 字数 498 浏览 5 评论 0原文

在某些时候,Visual Studio (2010) 停止解析所有 PhoneApplicationPage 上的任何静态资源(画笔、样式、ViewModel 定位器等)。然而,来自 UserControl 的任何 VisualEllement 都可以看到所有 StaticResources。

注意:所有资源之前都有效,并且 XAML 方面的页面没有任何更改。

知道为什么会发生这种情况吗?

临时修复:我想出的临时修复是将所有资源添加到 PhoneApplicationPage.Resources,以便在尝试在应用程序级别解析资源之前,元素将从 RD 解析它们电话应用程序页面。

编辑:在 Blend 中运行时,所有 StaticResources 都会得到解决,这个问题似乎只发生在 VS 中。此外,在解决方案中创建新页面时,它也无法解析任何静态资源。

At some point Visual Studio (2010) stopped resolving any static Resources (Brushes, Styles, ViewModel locators, etc.) on all PhoneApplicationPage. However any VisualEllement from with a UserControl can see all StaticResources.

Note: All resources worked before and there wasn't any changes to the pages in terms of XAML.

Any ideas why this is happening?

Temp fix: Temporary fix I came up with is to add All resources to PhoneApplicationPage.Resources so before trying to resolve resources at the application level, elements will resolve them from RD of the PhoneApplicationPage.

Edit: All StaticResources are resolved when running in Blend, this issues seems to happen only in VS. Also when creating a new Page in the solution it also can't resolve any StaticResources.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晨曦慕雪 2025-01-10 19:57:47

您可以尝试以下几件事。

  1. 创建一个新页面。您可以从那里访问静态资源吗?如果
    可以,您可以将原因缩小到页面的 xaml
    你现在遇到麻烦的地方。检查 xmlns 声明
    新的[年龄对照旧的来验证没有什么意外
    例如,已删除。
  2. 如果您有权访问 Expression Blend,请尝试
    打开那里的解决方案,然后右键单击一个元素
    应用资源。我有一种感觉,这个工具可能能够
    解决问题,但之前从未见过这种行为
    保证它。

另外,您的资源是在 app.xaml 中定义的,还是指定了包含资源的另一个文件?如果是后者,是否有管道以某种方式将额外的文件绑在擅离职守的地方?

There are a couple of things you could try.

  1. Create a new page. Can you access StaticResources from there? If
    you can, you can narrow down the cause to the xaml for the pages
    where you are having trouble now. Check the xmlns declarations from
    the new [age against the old to verify nothing has been accidentally
    removed, for example.
  2. If you have access to Expression Blend, try
    opening the solution there and then right-clicking on an element to
    apply a resource. I have a feeling that the tool might be able to
    fix issues, but never having seen this behaviour before I can't
    guarantee it.

Also, are your resources defined in app.xaml, or have you specified another file containing the resources? If the latter, has the plumbing to tie the extra file in gone AWOL somehow?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文