如何:为 Windows Presentation Foundation 独立导航应用程序创建示例项目文件
更新:2007 年 11 月
此示例项目文件适用于带有应用程序定义 App 的 Windows Presentation Foundation (WPF) 独立导航应用程序,该应用程序配置为自动打开一个页面 HomePage(该页面是利用可扩展应用程序标记语言 (XAML) 定义的并且是代码隐藏的)。HomePage 将在 NavigationWindow 中打开。主要配置详细信息包括:
OutputType。设置为 winexe。
App.xaml。此应用程序定义文件配置为 ApplicationDefinition 元素。
HomePage.xaml。声明为 Page 元素的 XAML 文件。
HomePage.xaml.cs。声明为 Compile 元素的代码隐藏文件。
您可以根据自己的需要重用或修改此项目文件,但前提是所引用的文件位于您正在从中引用文件的位置。或者,通过使用 Microsoft Visual Studio 2005 中的 Windows 应用程序 (WPF) 项目模板,并使用 Page 来替换默认 Window,您就可以获得一个自动生成的独立导航应用程序的项目文件。
此项目文件适用于 C# 项目,因此包括 Microsoft.CSharp.targets Import 元素。Microsoft Visual Studio 2005 为 C# 项目文件指定 .csproj 扩展名。在 Microsoft Visual Studio 2005 中创建的 Microsoft Visual Basic .NET 的扩展名通常为 .vbproj,并包括 Microsoft.VisualBasic.targetsImport 元素。
示例
<Project DefaultTargets="Build" xmlns="https://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<RootNamespace>WPFStandaloneNavigationApplication</RootNamespace>
<AssemblyName>WPFStandaloneNavigationApplication</AssemblyName>
<WarningLevel>4</WarningLevel>
<OutputType>winexe</OutputType>
<ApplicationVersion>1.0.0.*</ApplicationVersion>
<BootstrapperEnabled>false</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>.\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<Optimize>true</Optimize>
<OutputPath>.\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml" />
<Page Include="HomePage.xaml" />
<Compile Include="HomePage.xaml.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
</Project>