WPF LoadComponent问题绝对URI [英] WPF LoadComponent problem with absolute uri
问题描述
我宣布我的UI在外部XAML文件的一部分。我试图使用 Application.LoadComponent(URI)
加载它,但我得到一个异常告诉我,我不能用绝对URI。 XAML文件我想加载位于任意磁盘位置。
I have declared a part of my UI in an external XAML file. I am trying to load it using Application.LoadComponent(uri)
but I get an exception telling me that I cannot use absolute uris. The XAML file I want to load is located in an arbitrary disk location.
我已经成功地使用 LoadComponent
测试期间加载包含在我的项目XAML文件。在此之前,我已经尝试使用 XamlReader
但是这一次没有设置一些我用的XAML的附加属性。
I have successfully used LoadComponent
during testing to load XAML files included in my project. Prior to this I have tried using XamlReader
but this one didn't set some of the attached properties I was using in the XAML.
有没有办法实现这个还是我完全在错误的轨道?
Is there any way to achieve this or am I totally on the wrong track?
推荐答案
我已经解决了通过使用问题 XamlReader
。为什么以前没有工作的原因是因为我的附加属性的名称空间是没有组装=
部分中声明。并补充说, XamlReader
加载愉快XAML我的预期了。
I have resolved the problem by using XamlReader
. The reason why this did not work before is because the namespace for my attached property was declared without assembly=
part. After adding that, XamlReader
happily loaded my XAML as expected.
这篇关于WPF LoadComponent问题绝对URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!