System.Windows.Application.GetResourceStream 返回 null [英] System.Windows.Application.GetResourceStream returns null

查看:24
本文介绍了System.Windows.Application.GetResourceStream 返回 null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用 Catalog.xaml 作为内容调试 WPF 应用程序,则无法获取它的资源流 - GetResourceStream 返回 null:

If I debug a WPF-application with Catalog.xaml as Content, I can't get the resource stream of it - GetResourceStream returns null:

<代码>var uri = new Uri("/Assembly;component/Catalog.xaml", UriKind.Relative);
var foo = System.Windows.Application.GetResourceStream(uri);

foo 为空.我做错了什么?

foo is null. What am I doing wrong?

推荐答案

我相信对于类型 Content 你只需要项目名称:

I believe for type Content you only need the item name:

var uri = new Uri(**"Catalog.xaml"**, UriKind.Relative);
var foo = System.Windows.Application.GetResourceStream(uri);

这篇关于System.Windows.Application.GetResourceStream 返回 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆