gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 20:01:56 26 4
gpt4 key购买 nike

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

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com