简体   繁体   中英

WPF Resource Dictionary Build Action

I have a ResourceDictionary in a xaml file called SylesResourceDictionary.xaml in a Class Library Project. This ResourceDictionary is used in different views by Merging.

I'm new to ResourceDictionary and not sure if I'm doing it the right way. Different article suggest different Build Action Like Page and Custom Tool Like XamlIntelliSenseFileGenerator

  1. What should be the Build Action for this xaml file ? I have it set to Resource

  2. What should be the Custom Tool ? I have it set to MSBuildCompile

  3. Should I delete the xaml.cs file for this xaml file ?

  1. The Build Action of a ResourceDictionary should be set to Page .
  2. XamlIntelliSenseFileGenerator . Only the XAML compiler knows how to compile the XAML file to BAML.
  3. Yes, unless you have any custom code defined in the code-behind file. A ResourceDictionary may have a code-behind file but by default it's XAML only.

You may also want to consider creating a project using either the WPF Custom Control Library template or the WPF User Control Libary template instead of using the Class Library template. This will make it easier working with WPF and XAML specific types in Visual Studio. You will still be able to add any other types to the project as well.

In general:

  1. Page
  2. XamlIntelliSenseFileGenerator
  3. No!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM