共用方式為


HOW TO:建立 Windows Presentation Foundation 獨立巡覽應用程式的範例專案檔

更新:2007 年 11 月

這個範例專案檔代表一個 Windows Presentation Foundation (WPF) 獨立巡覽應用程式,其應用程式定義 (App) 已設定為自動開啟由可延伸標記語言 (XAML) 和程式碼後置 (Code-Behind) 所定義的頁面 (HomePage)。NavigationWindow 中將會開啟 HomePage。主要的組態詳細資料包括:

  • OutputType。設定為 winexe。

  • App.xaml。以 ApplicationDefinition 項目設定的應用程式定義檔案。

  • HomePage.xaml。以 Page 項目宣告的 XAML 檔案。

  • HomePage.xaml.cs。以 Compile 項目宣告的程式碼後置檔案。

只要要參考的檔案都位於您所參考的位置,您就能視需要重複使用或修改這個專案檔。另一種方式是,在 Microsoft Visual Studio 2005 中使用 Windows 應用程式 (WPF) 專案範本,並將預設的 Window 取代為 Page,以讓獨立巡覽應用程式的專案檔自動產生。

這個專案檔適用於 C# 專案,因此包含 Microsoft.CSharp.targetsImport 項目。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>