方法 : Windows Presentation Foundation スタンドアロン アプリケーションのサンプル プロジェクト ファイルを作成する

更新 : 2007 年 11 月

この例のプロジェクト ファイルは、Windows Presentation Foundation (WPF) のスタンドアロン アプリケーション用であり、ウィンドウを自動的に開くように構成されているアプリケーション定義 App、および Extensible Application Markup Language (XAML) と分離コードで定義されている MainWindow が格納されています。主な構成の詳細は次のとおりです。

  • OutputType: winexe に設定します。

  • App.xaml: ApplicationDefinition 要素として構成するアプリケーション定義ファイル。

  • MainWindow.xaml: Page 要素として宣言される XAML ファイル。

  • MainWindow.xaml.cs: Compile 要素として宣言される分離コード ファイル。

このプロジェクト ファイルは、必要に応じて再利用したり変更したりできます。ただし、参照するファイルは参照元の場所になければなりません。別の方法として、Microsoft Visual Studio 2005 で Windows アプリケーション (WPF) プロジェクト テンプレートを使用して、スタンドアロン アプリケーション用のプロジェクト ファイルを自動的に生成することができます。

このプロジェクト ファイルは 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>WPFStandaloneApplication</RootNamespace>

<AssemblyName>WPFStandaloneApplication</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="MainWindow.xaml" />

<Compile Include="MainWindow.xaml.cs" />

</ItemGroup>

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />

</Project>