HOW TO:建立 Windows Presentation Foundation 自訂控制項程式庫的範例專案檔
更新:2007 年 11 月
本範例專案檔適用於含有單一使用者控制項 WPFUserControl 的 Windows Presentation Foundation (WPF) 自訂控制項程式庫。主要的組態詳細資料包括:
OutputType。設定為 library。
WPFUserControl.xaml。宣告為 Page 項目的 XAML 檔案。
WPFUserControl.xaml.cs。宣告為 Compile 項目的程式碼後置 (Code-Behind) 檔案。
只要您參考的檔案都位於所要參考的位置,您便能視需要重複使用或修改此專案檔。或者,您也可以使用 Microsoft Visual Studio 2005 中的自訂控制項程式庫 (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>WPFCustomControlLibrary</RootNamespace>
<AssemblyName>WPFCustomControlLibrary</AssemblyName>
<WarningLevel>4</WarningLevel>
<OutputType>library</OutputType>
<ApplicationVersion>1.0.0.*</ApplicationVersion>
</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>
<Page Include="WPFUserControl.xaml" />
<Compile Include="WPFUserControl.xaml.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<AppDesigner Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
</Project>