在子文件夹中实现的窗口不适用于StartUri

Ste*_*and 7 .net c# wpf xaml

关于WPF的新手问题.

我刚刚开始一个项目草案.我已经定义了一个非常简单的窗口testWindow1.xaml,位于解决方案子文件夹Tests中.

在App.xaml我不能做:

StartupUri="testWindow1.xaml"
Run Code Online (Sandbox Code Playgroud)

(除非我将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">
Run Code Online (Sandbox Code Playgroud)

在运行时,异常消息抱怨没有找到ressource*testWindow1.xaml

Roh*_*ats 14

试试这个 -

<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">
Run Code Online (Sandbox Code Playgroud)

您只需指定层次结构.