问题描述
||
警告1在项目文件中找不到文件\'........ \\ Window1.xaml.cs \'的父文件\'Window1.xaml \'。 WpfApplication1
为什么会这样呢?
编辑:打开wpfapplication1.csproj文件:
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<Project Toolsversion=\"3.5\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">
<PropertyGroup>
<Configuration Condition=\" \'$(Configuration)\' == \'\' \">Debug</Configuration>
<Platform Condition=\" \'$(Platform)\' == \'\' \">Anycpu</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1656975F-4108-4386-80CB-00176DF48895}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WpfApplication1</RootNamespace>
<AssemblyName>WpfApplication1</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=\" \'$(Configuration)|$(Platform)\' == \'Debug|Anycpu\' \">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\\Debug\\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=\" \'$(Configuration)|$(Platform)\' == \'Release|Anycpu\' \">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\\Release\\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include=\"System\" />
<Reference Include=\"System.Core\">
<requiredTargetFramework>3.5</requiredTargetFramework>
</Reference>
<Reference Include=\"System.Windows.Forms\" />
<Reference Include=\"System.Xml.Linq\">
<requiredTargetFramework>3.5</requiredTargetFramework>
</Reference>
<Reference Include=\"System.Data.DataSetExtensions\">
<requiredTargetFramework>3.5</requiredTargetFramework>
</Reference>
<Reference Include=\"System.Data\" />
<Reference Include=\"System.Xml\" />
<Reference Include=\"WindowsBase\" />
<Reference Include=\"PresentationCore\" />
<Reference Include=\"PresentationFramework\" />
</ItemGroup>
<ItemGroup>
<ApplicationDeFinition Include=\"App.xaml\">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDeFinition>
<Page Include=\"Window1.xaml\">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include=\"App.xaml.cs\">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include=\"..\\..\\..\\..\\Window1.xaml.cs\">
<DependentUpon>Window1.xaml</DependentUpon>
<SubType>Code</SubType>
<Link>Window1.xaml.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include=\"Properties\\AssemblyInfo.cs\">
<SubType>Code</SubType>
</Compile>
<Compile Include=\"Properties\\Resources.Designer.cs\">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include=\"Properties\\Settings.Designer.cs\">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include=\"Properties\\Resources.resx\">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<None Include=\"Properties\\Settings.settings\">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include=\"Properties\\\" />
</ItemGroup>
<Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />
<!-- To modify your build process,add your task inside one of the targets below and uncomment it.
Other similar extension points exist,see Microsoft.Common.targets.
<Target Name=\"BeforeBuild\">
</Target>
<Target Name=\"AfterBuild\">
</Target>
-->
</Project>
您如何在这里分析文件路径?我不太明白解决方法
如果在文本编辑器中检查WpfApplication1.csproj文件,则该文件应具有Window1.xaml和Window1.xaml.cs文件的条目。
您必须确保xaml和CS文件位于项目文件认为的位置。,尝试更改文件“ 2”在“ 1”中的路径,
<ItemGroup>
....
<Compile Include=\"Window1.xaml.cs\"> <!--Changed path-->
<DependentUpon>Window1.xaml</DependentUpon>
<SubType>Code</SubType>
<Link>Window1.xaml.cs</Link>
</Compile>
</ItemGroup>