c# - 在 StartUri 不可用的子文件夹中实现的窗口

标签 c# .net wpf xaml

一个关于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/

相关文章:

C# - DataGridView 在 Cell 中换行文本但没有空格

javascript - MMS 是否支持发送 HTML 内容?

c# - 断言列表中字段的唯一性

c# - 在 C# 中通过字符串获取成员?

c# - 解决方案资源管理器中的引用未更新

.net - 在 C :\Program Files\Program instead of C:\Program Files\Manufacturer\Program Name 上安装程序

c# - PayPal Rest API - 使用更新的交易信息执行付款

c# - 在 WPF 中为 DataGridRow 创建 ControlTemplate

c# - Shift+Tab 在 TreeView 控件中不起作用

wpf - 如何支持具有相同 View 模型的多个 View ?