简体   繁体   English

[UWP] [C ++]如何更改App.xaml的位置

[英][UWP][C++] How to change location of App.xaml

I'm leaning programming on UWP using C++. 我倾向于使用C ++在UWP上进行编程。

I created sample by using New Project -> Visual C++ -> Windows -> Universal -> Blank App (Universal windows). 我通过使用新建项目-> Visual C ++-> Windows->通用->空白应用程序(通用窗口)创建了示例。 This sample can be compiled without error and run correctly. 可以正确无误地编译此示例并正确运行。

The problem is, I want to move all source files (xaml, cpp, h) into a subfolder named "src" for managing. 问题是,我想将所有源文件(xaml,cpp,h)移动到名为“ src”的子文件夹中进行管理。

It will look like this: 它看起来像这样:

root project directory 根项目目录

| | -- Assets -资产

| | -- src -src

| | | | -- App.xaml -App.xaml

| | | | -- App.xaml.cpp -App.xaml.cpp

| | | | -- App.xaml.h -App.xaml.h

| | | | -- (the rest files: mainpage, subpage, etc.) -(其余文件:主页,子页面等)

| | -- Sample.sln -Sample.sln

| | -- Sample.vcxproj -Sample.vcxproj

| | -- Package.appxmanifest -Package.appxmanifest

But after moving those files and changing all paths related to them in vcxproj , I couldn't compile the project. 但是在移动了这些文件并更改了vcxproj中与它们相关的所有路径之后,我无法编译该项目。

The error I got is " XamlCompiler error WMC1008: Application main file must be named App.xaml". 我得到的错误是“ XamlCompiler错误WMC1008:应用程序主文件必须命名为App.xaml”。

This is new ApplicationDefinition field in the vcxproj file 这是vcxproj文件中的新ApplicationDefinition字段

 <ApplicationDefinition Include="src\App.xaml">
      <SubType>Designer</SubType>      
    </ApplicationDefinition>
    <Page Include="src\MainPage.xaml">
      <SubType>Designer</SubType>
    </Page>

I'm pretty sure that we can change the location of App.xaml because the offical samples on https://github.com/Microsoft/Windows-universal-samples can do it, but they put them in a parent folder. 我非常确定我们可以更改App.xaml的位置,因为https://github.com/Microsoft/Windows-universal-samples上的官方示例可以做到,但是它们将它们放在父文件夹中。 I inspected those samples but still couldn't find out how to do that. 我检查了这些样本,但仍然找不到该怎么做的方法。

Could you please help me :) 请你帮助我好吗 :)

Due to the restriction of Windows Store Applications, you could not move the "App.xaml" relevant files to other sub folders. 由于Windows Store应用程序的限制,您无法将“ App.xaml”相关文件移动到其他子文件夹。

What you see in the UWP official samples. 您在UWP官方样本中看到的内容。 The samples actually use the <Link> element to virtually move files around. 样本实际上使用<Link>元素来虚拟移动文件。 When you open a project, you will find that the "App.xaml" file will still be copied into the root directory. 当您打开一个项目时,您会发现“ App.xaml”文件仍将被复制到根目录中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM