一个关于WPF的新手问题。
我刚刚开始一个草稿项目。 我定义了一个非常简单的窗口 testWindow1.xaml,位于解决方案子文件夹 Tests 中。
在 App.xaml 中我不能这样做:
StartupUri="testWindow1.xaml"
(除非我将 testWindow1.xaml 移回项目的根目录)
我也曾尝试将我的命名空间定义到 App.xaml 标记中,但没有成功,这也行不通。
<Application x:Class="MyProject.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:myprojectNS="clr-namespace:MyProject"
StartupUri="myprojectNS.tests.testWindow1.xaml">
在运行时,异常消息提示找不到资源 *testWindow1.xaml
最佳答案
试试这个-
<Application x:Class="MyProject.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:myprojectNS="clr-namespace:MyProject"
StartupUri="tests\testWindow1.xaml">
您只需要指定层次结构即可。
关于c# - 在 StartUri 不可用的子文件夹中实现的窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5694273/